Free tool · BigQuery cost guardrail
BigQuery maximum bytes billed: a per-query cost guardrail
Decide what one query may cost, and get the byte ceiling that enforces it — with the bq query flag and the Python client setting to paste into your code or a code review.
What maximum bytes billed does
On on-demand pricing BigQuery charges for the bytes a query processes, per TiB (binary: 1 TiB = 240bytes). The maximum bytes billed setting puts a ceiling on one query: if the query would bill more bytes than the limit, it fails without incurring a charge. A budget per query is therefore a byte count — the budget divided by your price per TiB.
BigQuery bills at least 10 MB per query and per table it references, and rounds up to the nearest MB, so a ceiling must leave room for that. On a capacity (slot) reservation you pay for slots, not bytes, and a byte ceiling does not cap that cost. To limit what a whole day of queries can process for a project or a user, Google offers custom quotas instead.
Google's documentation, checked on 2026-10-31:limit query costs by restricting the number of bytes billed,BigQuery pricing,bq query andQueryJobConfig.
1. Enter a budget for one query
2. The byte ceiling
3. Apply it to a query
Both examples run a dry run first, which reports what the query would process without running it, then run the query with the ceiling. The SQL and names are placeholders.
Replace the placeholders
your-project-id: the project that runs, and pays for, the query.your_dataset.your_table: the dataset and table your query reads.column_a, column_b and event_date: your own query: everything between the quotes is a stand-in.
Keep the ceiling as a whole number of bytes. In bq, keep the SQL inside single quotes so the shell leaves the backticks alone, and --use_legacy_sql=false for GoogleSQL. The Python needs thegoogle-cloud-bigquery package and credentials that can run queries in the project.
Check that it works
- Run the dry run first. It reports the bytes the query would process without running it; if that is more than the ceiling, expect the real run to be refused.
- Run the query with the ceiling. A query that would bill more than the limit fails with an error about the bytes billed limit, and Google does not charge for it.
- When it succeeds, compare its bytes billed with the ceiling: total_bytes_billed on the Python job, or the total_bytes_billed column for its job_id in INFORMATION_SCHEMA.JOBS_BY_PROJECT.
- To see a refusal on purpose, set the ceiling below the dry run's figure (but at 10 MiB or more) and run it again: it should fail without billing anything.
What this calculator assumes and leaves out
- On-demand compute only: the ceiling limits the bytes one query may bill, priced per TiB. Bytes are binary: 1 TiB = 1,024 GiB = 2^40 bytes, and the ceiling is rounded down to a whole byte so it never exceeds the budget.
- One query at a time. A ceiling does not limit how often a query runs or what a day of queries costs; BigQuery's custom quotas do that for a project or a user.
- On a capacity (slot) reservation you pay for slots, not bytes, so a byte ceiling does not cap that cost.
- The prefilled price is an example: Google's US on-demand list price on 2026-10-31. Your region and contract may differ — enter your own.
- BigQuery bills at least 10 MB per query and per table referenced, and rounds up to the nearest MB, so a small ceiling must leave room for that.
- Not included: the free first TiB a month, cached results (which bill nothing), storage, streaming inserts, the Storage API, data transfer, taxes, credits, discounts and other contract adjustments.
Know the workload behind the limit
A ceiling stops one expensive query; it does not say which queries need one. dwhat's audit reads your BigQuery query history and estimates on-demand compute by day, user, dbt model and dashboard, with the most expensive queries and what they billed — the figures to set these limits from.
Related guides
- Fixes for expensive BigQuery and Snowflake queries, and how to tell which appliesSeven fixes BigQuery, Snowflake and dbt document — full scans, SELECT *, LIMIT, spilling, pruning, dbt full rebuilds, repeated queries — each with SQL that finds the queries it applies to.
- Find your most expensive BigQuery queries with SQLCopy-paste SQL that lists the BigQuery queries that cost the most over the last 30 days, from INFORMATION_SCHEMA.JOBS_BY_PROJECT, with bytes billed, slot hours and estimated cost.