A per-question scan budget in BigQuery belongs in the job configuration, set with maximum_bytes_billed, because a query whose estimate exceeds it fails before execution without a charge. Pair it with a dry run for a friendly preview and custom quotas for a daily ceiling, then audit actual use in INFORMATION_SCHEMA.JOBS. Adding LIMIT does not reduce the data read on a non-clustered table. On tables with row-level access policies, dry runs report 0 bytes and the JOBS byte columns are empty, so plan that case separately.
A prompt cannot hold a budget
Telling a model to write efficient queries is a suggestion. An agent that explores data will eventually run SELECT * across a multi-year events table, and on-demand pricing bills it for what it read. The control has to sit somewhere the model cannot talk its way past, and BigQuery provides three, working at different scopes.
The first is per job. maximum_bytes_billed caps a single query: BigQuery estimates the bytes before execution, and if the estimate is over the cap the job fails with bytesBilledLimitExceeded and costs nothing. The second is per day. Custom quotas limit data processed per project, or per user across a project, and once one is reached the affected users cannot run queries. Google notes that the per-user quota applies to everyone in the project alike, so you cannot give one application identity its own number. The third is by table: require_partition_filter rejects any query without a predicate that can eliminate partitions, including queries through views that reference the table.
Work the budget out from one question
Choose the number from a real question so the cap has a reason behind it. Consider a synthetic scenario, with every figure invented: an events table holds 18 TB across three years, partitioned by day on a 40-column schema. Someone asks for one month of purchases by region. Reading the table whole would process 18 TB. A filter on the partitioning column cuts that to about 500 GB, and selecting the five columns the aggregate needs, which in this example hold 12 percent of the bytes, brings it to about 60 GB.
In that synthetic scenario, a cap of 100 GB would pass the query with some margin and reject the version that forgot the date filter or selected every column. Set it from the 95th percentile of the questions you want to allow, and treat the first month’s number as a draft.
Partition filters have sharp edges that generated SQL hits often. Pruning needs a constant expression with the partitioning column on its own. A comparison with a subquery result, such as a filter on the latest date in another table, does not prune, and neither does arithmetic on the column or an OR with a non-partition column. A model that writes the clever subquery version pays for the full table, or hits the cap, for a question that looks tightly bounded when you read it. Testing with a dry run shows which you have.
# Preview: reports bytes that would be processed, uses no slots, costs nothing
bq query --use_legacy_sql=false --dry_run \
'SELECT region, SUM(amount) AS purchases
FROM analytics.events
WHERE event_date BETWEEN "2026-09-01" AND "2026-09-30"
AND event_type = "purchase"
GROUP BY region'
# Run: fails with bytesBilledLimitExceeded if the estimate is over the cap
bq query --use_legacy_sql=false \
--maximum_bytes_billed=107374182400 \
--label=app:answers \
'SELECT region, SUM(amount) AS purchases
FROM analytics.events
WHERE event_date BETWEEN "2026-09-01" AND "2026-09-30"
AND event_type = "purchase"
GROUP BY region'Why a sensible query can still fail
Expect refusals your users will find unfair, and decide how to handle them before they happen. The estimate that gets compared with your cap can be larger than what the query would bill. For clustered tables it is an upper bound worked out before cluster pruning, so filtering on a clustered column lowers the actual bill and leaves the estimate alone. With synthetic figures, a query that would have billed 20 GB can be rejected by a 100 GB cap because the matching partitions total 300 GB. On-demand pricing also has a 10 MB minimum for each referenced table.
LIMIT behaves the other way round from what many people assume. On a non-clustered table it does not reduce the data read at all, so a LIMIT 100 query can scan the whole table. On clustered tables scanning can stop early, so LIMIT may lower the bytes billed. Either way, a capped row count says nothing about whether an aggregate over those rows is complete. That’s a correctness concern as well as a cost one.
The worst way to handle a refusal is to retry with a narrower date range, say nothing, and report the result as though it answered the question. A narrower total is a different answer. A system that narrows the scope has to tell the reader what was left out.
Row-level security removes your instruments
Most budget guides leave this part out. BigQuery hides sensitive statistics for queries against tables with row-level security, including bytes processed, partitions processed, bytes billed and query plan stages. A dry run on such a table always returns 0 bytes, to prevent side-channel attacks. In INFORMATION_SCHEMA.JOBS, total_bytes_processed and total_bytes_billed are empty for queries that read those tables.
Three things follow. A preflight check that compares a dry-run figure with a threshold will pass every query on these tables, because 0 is always under budget. Your audit totals will undercount with no warning, because SUM skips NULL. And a friendly error message that repeats the required bytes may tell a filtered user something about data they cannot see: Google’s guidance warns that limit errors such as maximum bytes billed can let someone infer bytes processed. That warning suggests the cap is still enforced on these tables, but Google does not state it outright, so test it in your own project with a throwaway table before relying on it. Lean on quotas and on reviewed table design there, and keep failure messages generic for people on filtered tables.
Audit what ran
INFORMATION_SCHEMA.JOBS holds 180 days of job history. It needs a region qualifier, and it is partitioned by creation_time, so filter on that column or your audit query becomes a good example of the problem. Google lists bigquery.jobs.listAll and bigquery.jobs.create as the required permissions, through the BigQuery Resource Viewer and BigQuery User roles. Exclude statement_type SCRIPT from totals, since a multi-statement parent job carries summary values for its children and they would otherwise count twice.
Count the NULLs alongside the sum. The rls_hidden column below is an approximation, since jobs still running also have empty values, but a high figure tells you how much of your spending this report cannot see. Cached results are a separate gap to expect: they are not billed, cache_hit marks them in the job statistics, and the cache is per user and per project unless you are on an edition that offers cross-user caching. Queries over row-level secured tables are not cached at all, which raises their repeat cost compared with an otherwise identical unsecured table.
Capacity-based projects need a different reading. Under flat-rate pricing total_bytes_billed is informational only, so watch total_slot_ms as your measure of what a question used.
SELECT user_email,
COUNT(*) AS jobs,
COUNTIF(cache_hit) AS cached,
COUNTIF(total_bytes_billed IS NULL
AND NOT cache_hit
AND error_result IS NULL) AS rls_hidden,
SUM(total_bytes_billed) AS bytes_billed,
SUM(total_slot_ms) AS slot_ms,
COUNTIF(error_result.reason = 'bytesBilledLimitExceeded') AS over_budget
FROM `my-project`.`region-us`.INFORMATION_SCHEMA.JOBS
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
AND job_type = 'QUERY'
AND statement_type != 'SCRIPT'
GROUP BY user_email
ORDER BY bytes_billed DESC;Cheaper can mean wrong
Every one of these savings changes which rows get read, so each one needs a check on meaning. The usual trap is the partition column. If a table is partitioned by ingestion time and the question is about purchase date, filtering on the partition drops late-arriving events. Ingestion-time partitions are also based on UTC, which may disagree with your reporting time zone at a month boundary. The data owner should decide how the two dates work together, and the rule belongs next to the table definition where a generator can read it.
Before you lower a cap or narrow a default, retest with a late-arriving event, a boundary timestamp and a null region. Compare the total with a report finance or the owner already trusts. Each one exercises a place where a well-meant optimization can change the answer without raising an error.
Push it over budget on purpose
For an AI analytics product on BigQuery, ours or anyone’s, ask for one recurring question and its reference report, then run it under the same permissions the real users hold. Check in JOBS which identity ran the job and what it billed. Then push it over the budget on purpose and read what the person is told. I want it to name the limit and what was left out. Our connector catalog is at https://nexatron.io/connectors.
Bring three business questions
Explore your sources, definitions, and review criteria with our team. Please keep credentials and sensitive records out of the inquiry.