Maximum Bytes Billed Query Caps in BigQuery

A per-query cap stops giant scans, but only layered controls stop the rest.

· 8 min read
Cover illustration for “Maximum Bytes Billed Query Caps in BigQuery”
BigQuery Cost Controls · November 28, 2026 · 8 min read · 1,851 words

Maximum bytes billed is BigQuery’s hard per-query guardrail for on-demand query costs. It stops an oversized scan before it incurs a charge, but it cannot stop a loop of smaller queries or replace good table design. Real cost control depends on understanding that boundary and combining the cap with partitioning, dry runs, daily quotas, and reporting.

Why BigQuery's billing model makes cost surprises structurally inevitable

BigQuery’s on-demand model bills for bytes scanned. A small result can require a large scan. SELECT * reads every column across the partitions touched, including columns nobody needed, while LIMIT 10 limits only the output, leaving the scan unchanged. The same question can therefore cost orders of magnitude more when its query omits a partition filter.

This exposure follows from an architectural strength. Compute and storage are separate, so idle query compute does not generate scan charges, and infrastructure size does not constrain the cost of a poorly shaped query. A runaway job or dashboard refresh loop can thus run up a large bill before anyone notices. Small queries have their own trap because charges round up to the nearest MB, with a minimum of 10 MB per table referenced and per query.

The default project quota permits a large daily volume, while the per-user quota is unlimited unless configured. There is no automatic per-query spending limit waiting to catch a mistake. Closing that gap requires explicit controls at the points where queries enter and consume the system.

What maximum bytes billed actually does — and what it does not

Maximum bytes billed compares BigQuery’s pre-execution byte estimate with a configured limit. If the estimate exceeds that limit, the query fails without incurring a charge. The stop happens before the scan begins. This catches an unfiltered full-table scan or a misconfigured join when its estimated bytes exceed the allowance.

But what happens when an expensive query stays just below the limit? It runs, including when it runs hundreds of times. The setting neither totals daily spending nor detects a query’s gradual growth while it remains within the allowance. It also provides no protection for jobs submitted through a surface where it was never configured.

A dry run helps test the boundary without running the query. Its estimate reflects partition pruning, so it can show whether a partition filter reduces the expected scan. Some estimates need particular care. Dry runs return no bytes for tables with row-level security and can underreport external tables, leaving the enforced cap as the hard backstop rather than making the preview a complete cost guarantee.

For clustered tables, the byte estimate is an upper bound, and actual billed bytes can be lower after execution because clustering benefits may not appear in the estimate. A query can therefore fail even though its eventual charge would have fit. Allowing margin reduces those false failures, but also makes the control less precise on tables designed to reduce scans.

Where and how to set the cap — API, CLI, dbt, and agent surfaces

The setting must be in place on every surface used to submit queries. There is no project-wide default that automatically covers all jobs. For the command-line interface, the option is bq query --maximum_bytes_billed, while API jobs use the maximumBytesBilled property in their configuration. BI tools such as Looker need the limit in their connection configuration, so dashboard access does not become an unguarded route.

For dbt, maximum_bytes_billed belongs in the BigQuery profile and applies to every query job run with that profile. Setting it to 1099511627776 allows 1 TiB per query as an example allowance. A scheduled model with a misconfigured join then fails before scanning if its estimate exceeds the configured allowance, protecting the daily budget from unchecked consumption.

Agent access needs equally explicit treatment because unattended iteration changes the exposure. In the agent flow described here, a trial run estimates the scan before the query runs, and an estimate over the limit returns an error without a charge. The API also imposes a minimum permitted value, so an arbitrarily tiny setting can itself return an error.

The Toolbox environment variable is not evidence that the same configuration applies to a managed MCP connection. After execution, totalBytesProcessed and totalBytesBilled make usage visible, but neither field prevents spending. An agent can keep submitting queries that fit under its cap, so controls on what it submits are only part of managing its access.

Why maximum bytes billed alone is not enough — and what fills the gaps

Diagram: The Five-Layer BigQuery Cost Control Stack. Visualizes: The article describes five complementary controls that together govern BigQuery on-demand costs, each addressing a gap the others cannot fill: (1) Table design — partitioning +…

Before a change merges, dry-run scripts or CI actions can flag a rise in the bytes each run is expected to read. This catches a regression before it ships. It does not cover ad hoc queries, work outside the repository, or data that grows later, so passing a check cannot mean a query’s cost is approved for good.

When the query runs, table design determines how much it needs to read. Partitioning on the column people filter by, usually a date, narrows the scan to relevant history. Clustering then lets BigQuery skip blocks within partitions. Setting require_partition_filter = TRUE rejects queries without a usable partition filter, but does not restrict how many partitions that filter retains. A qualifying predicate must reference only the partitioning column, with other predicates combined using AND, since an OR defeats pruning.

Maximum bytes billed then catches a scan that passes those checks but is still too large. Daily quotas address the repetition it misses. QueryUsagePerDay and QueryUsagePerUserPerDay provide project and user safeguards, with further queries failing with quotaExceeded once the quota is reached, until midnight Pacific Time. They apply to on-demand pricing and can interrupt important scheduled work as well as wasteful queries.

After queries run, budgets and INFORMATION_SCHEMA.JOBS help explain what was spent and which jobs spent it. They do not stop queries themselves. A Cloud Run function subscribed to a Pub/Sub budget notification can lower a custom quota or page on-call at a defined threshold, though automatic actions should stay conservative and reversible. This reporting layer supplies the attribution that an aggregate quota lacks, making it possible to distinguish a bad change from repeated legitimate work.

What the controls look like in practice — measured results from real workloads

A measured dbt-BigQuery experiment used a profile with maximumBytesBilled set to 1 GB and compared a filtered query over one month with the full table. The filtered query read a small fraction of the data. Billed bytes fell less than processed bytes because the filtered run reached the 10 MiB per-query minimum. The result exposes both the value of narrowing scans and the billing floor that remains afterward.

Table structure can produce much larger changes before that floor is reached. The workload measurements include a reduction of well over an order of magnitude after partitioning and clustering. A query costing tens of dollars on a large unpartitioned table can fall below a dollar when date partitioning restricts it to the relevant data. These gains come from avoiding reads.

Koritsu AI’s assessment of a UK bidding platform found that its highest-billed queries all lacked partition predicates, despite using already-partitioned tables. Every one was performing a full-table scan. Adding the partition-column WHERE clause, along with staging-dataset expiration policies and a slot reservation sized to fit the work, brought cloud costs down across three consecutive monthly invoices. Because several changes contributed, the result does not isolate the savings from filtering alone.

Lightdash merged a PR that added dry-run cost estimates to BigQuery connections and enforced a limit on queries run by agents. The estimate made exposure visible before execution, while the cap remained the backstop for unattended iteration. Frequency still creates a separate problem. Event-driven pipelines and real-time dashboards issuing hundreds of small queries per minute can repeatedly hit the per-table billing minimum, a cost neither partition filters nor an individual query cap eliminates.

How to calibrate the byte limit — picking numbers that protect without breaking things

Querying INFORMATION_SCHEMA.JOBS_BY_PROJECT over a representative recent period reveals daily billed bytes by user and job type, as well as the largest jobs. Those are different signals for different controls. How much each user uses in a day helps set daily quotas, while the size of each job helps set query limits for each workload.

Separate workloads before choosing allowances. BI service accounts can use tighter limits when their queries should hit partitioned, clustered tables, while batch ELT jobs may legitimately require larger scans. Agent service accounts should have a separate, lower allowance because they iterate unattended. Separate projects for exploration, BI, and pipelines also keep one workload’s daily quota exhaustion from stopping the others.

Next, test the planned query limits with dry runs and leave a clear margin for clustered-table estimates. Too little margin turns normal work into failures. Too much leaves the guardrail largely decorative, so the choice should follow expected query behavior rather than a wish to eliminate every possible interruption. For daily user quotas, the p90 of observed daily usage plus a buffer provides a starting point, with the user allowance below the project quota so one analyst or notebook loop cannot consume the whole day.

Enforcement also needs a visible failure path. Alerts on quotaExceeded errors in Cloud Logging can expose interrupted jobs, with notifications sent to Pub/Sub rather than only email so a response can be automated. A low-disruption rollout begins by adding the byte cap to every service account’s tooling, then requiring partition filters on large tables and setting user and project quotas. Budget alerts with Pub/Sub notifications follow, with weekly review of INFORMATION_SCHEMA to tune the controls as usage changes.

Where maximum bytes billed fits in a broader cost architecture — and what it cannot substitute for

The byte cap governs on-demand query processing. It has no effect on storage costs, streaming inserts, or the BigQuery Storage API. Editions reservations use a different cost lever, namely autoscaler maximum slots. Choosing between those models therefore requires a view of the workload, rather than treating a byte limit as a universal spending policy.

On-demand pricing remains a sensible default for spiky, unpredictable, ad hoc use. A 100-slot Enterprise reservation kept for the whole month costs thousands of dollars, while Standard costs less at list rates and has a lower equivalent scanning volume. Below the crossover, tightly controlled on-demand usage costs less than a reservation, so buying slots solely for predictability can mean paying for capacity that low, uneven usage does not justify.

On-demand is the cheaper choice until monthly spending is high and steady enough for reserved capacity to cost less. Agent traffic also calls for a separate choice of where to run exploratory loops, including whether they belong on the production warehouse. ObsessionDB is one option for moving that traffic elsewhere, offering a managed service built for agentic workloads with isolated read-only compute, full query logging, and compute-hour pricing. That model has no per-scan charge for a byte cap to guard against.

For teams remaining on BigQuery, table design reduces ordinary scans, quotas constrain repetition, and reporting shows where the policy needs adjustment. A pricing or architecture change becomes relevant when those controls reveal a workload whose economics have changed.

More in BigQuery Cost Controls