Request a demo

BigQuery error · Resources and limits

Query exceeded resource limits (CPU per bytes billed)

On-demand pricing charges by bytes scanned, so BigQuery caps how much CPU a query may burn per byte: about 256 CPU seconds per MiB scanned. A query that reads little data but computes a lot (an exploding join, a range join, heavy regex or JavaScript UDFs) fails. Reduce the computation, or run it on editions slots.

Error reason billingTierLimitExceeded · HTTP 400 · Checked against the Google Cloud docs in November 2026

The error message

Query exceeded resource limits. This query used <cpu_seconds_used> CPU seconds but would charge only <analysis_megabytes_billed>M Analysis bytes. This exceeds the ratio supported by the on-demand pricing model. Please consider moving this workload to a capacity-based pricing model, which does not have this limit. <cpu_seconds_used> CPU seconds were used, and this query must use less than <cpu_seconds_limit> CPU seconds.

Causes

A join that multiplies rows

A CROSS JOIN, or a join on a key that repeats on both sides, turns two small tables into billions of row pairs. The bytes billed stay small because the inputs are small, while the CPU time explodes. Duplicate keys in a dimension table are a frequent unintended version of this.

Inexact join conditions

Range joins such as ON e.event_ts BETWEEN s.start_ts AND s.end_ts or joins on LIKE or REGEXP_CONTAINS can't use a hash join, so every left row is compared with every right row.

Heavy per-row computation

Complex regular expressions, JavaScript UDFs, JSON parsing of large strings, or geography functions on every row of a small table use a lot of CPU per byte read.

Window functions over a huge unpartitioned window

OVER (ORDER BY ...) without PARTITION BY, or a frame that recomputes over many rows for each row, costs CPU that grows faster than the data scanned.

How to fix it

1. Check join keys for duplicates before joining

Count keys on both sides. If the right side should be unique per key, deduplicate it first; the row explosion is usually a data problem, not a query problem.

SELECT customer_id, COUNT(*) AS rows_per_key
FROM `project.dataset.customers`
GROUP BY customer_id
HAVING COUNT(*) > 1
ORDER BY rows_per_key DESC
LIMIT 20;

2. Turn a range join into an equality join plus a filter

Add an equality condition that narrows the candidates, such as the same user and the same day, then keep the range condition as a filter. BigQuery can hash-join on the equality part.

SELECT e.event_id, s.session_id
FROM `project.dataset.events` AS e
JOIN `project.dataset.sessions` AS s
  ON e.user_id = s.user_id
 AND e.event_date = s.session_date
WHERE e.event_ts BETWEEN s.start_ts AND s.end_ts;

3. Partition window functions and pre-aggregate

Give every window a PARTITION BY, and aggregate to the grain you need before joining or windowing, so each step handles fewer rows.

4. Replace JavaScript UDFs and heavy regex

Built-in functions and SQL UDFs are much cheaper than JavaScript UDFs. Prefer STARTS_WITH, CONTAINS_SUBSTR or SPLIT over a regular expression when they express the same test.

5. Run the workload on capacity (editions) slots

The CPU-per-byte ratio applies only to on-demand pricing. Assigning the project to a reservation removes it, but then you pay for the slot time the query burns, so fix the query first. Compare both models on BigQuery pricing.

How to prevent it

  • Look at the query's Execution details: a stage whose output rows are far above its input rows is the join that explodes.
  • Track failed jobs with error_result.reason = 'billingTierLimitExceeded' using the failed jobs cost query; under editions the same query would have succeeded and quietly used a lot of slot time.
  • Enforce unique keys on dimension tables with a data test before they are joined.

FAQ

Am I charged for a query that fails with billingTierLimitExceeded?

No. It only happens on on-demand pricing, and on-demand queries that return an error aren't charged. The work it did is lost, though, and a retry fails again unless the query changes.

What is the CPU limit per byte on on-demand?

Google documents a limit of approximately 256 CPU seconds per MiB of scanned data for on-demand queries. Capacity-based (editions) pricing has no such ratio.

Should I just move the project to editions?

Only if the computation is intended. Under editions the same query runs, but it is billed by slot time, and an accidental row explosion can then use more slot-hours than a whole day of normal work. Fix unintended joins first.

SQL reference

More resources and limits

All BigQuery error messages · What 50M daily events say about BigQuery failures

Stop finding BigQuery failures in Slack threads

Masthead watches every BigQuery job, dbt model, Dataform action and Airflow task from audit logs, groups failures into incidents and shows which tables and dashboards are affected. No access to your data and no added BigQuery cost.