Partition Pruning Verification With BigQuery Dry Runs
Comparing estimated bytes with and without the filter shows whether pruning works.

BigQuery dry runs make partition pruning testable before a query spends anything. The key is to compare estimated bytes with and without the partition filter, then use job records when planning-time estimates cannot settle the question.
How BigQuery's dry-run API works and what it actually measures
A dry run validates SQL and reports the estimated bytes a query will scan without executing it. It costs nothing and uses no query slots. In the console, the query editor shows the estimate as you type. Through the REST API or a client library, submit a job configuration with dryRun set to true, then read totalBytesProcessed from the response. The result estimates scan volume at planning time, before any work executes.
That distinction is what makes the estimate useful for partition verification. The planner can resolve partition metadata, including which partitions exist and which predicates eliminate them, before reading the underlying data. BigQuery separates its storage system, Colossus, from its compute system, Dremel, connecting them through Jupiter’s high-bandwidth network fabric. A filter that excludes partitions at this stage therefore changes the bytes reported by the dry run.
Why partition pruning cannot be assumed to be working just because a partitioned table exists
A partitioned table gives the planner something to skip, but the query must tell it what can be skipped. The WHERE clause is the deciding point. For a straightforward pruning predicate, the partition column appears by itself on one side of a comparison, against a value that can be resolved before execution. That value might be a literal, a constant expression, or a supported built-in whose result is known at planning time.
Wrapping a TIMESTAMP partition column in DATE(event_timestamp) can obstruct the direct comparison needed to identify a partition range. Comparing the partition column with a subquery result or another table column also introduces a value that may be unknown until execution. The wrong column creates a different failure. On an ingestion-time partitioned table, an event_date or created_at filter can select the right business records without restricting _PARTITIONTIME or _PARTITIONDATE.
Why is this easy to miss? The SQL can compile, run, and return the right results while scanning far more data than was intended. Correctness does not reveal the physical work. On a large table with hundreds of daily partitions, a narrow filter that prunes correctly reads a small share of what a full-table scan would read. Under on-demand pricing, that difference makes pruning a substantial cost control.
The dry-run comparison: the check to run before a query ever executes
To test a query in the console, first paste the version containing the partition filter into the editor. Read the byte estimate in the upper-right corner without running the query. This is the filtered measurement. Next, remove the partition filter and read the estimate again, keeping the rest of the query the same. The comparison isolates the contribution of that filter instead of mixing it with changes to the selected columns or other query logic.
The API procedure follows the same two steps. Submit the filtered query with dryRun set to true and record totalBytesProcessed. Then submit the same query without its partition filter, again as a dry run, and compare the returned value. Neither submission executes the query. This makes the check suitable both for query development and for automated review, where the same comparison can be made without manually reading the console.
For a narrow literal or constant-expression filter, a sharp drop in estimated bytes shows that the planner is excluding partitions. An unchanged estimate calls for closer inspection. If both versions remain at or near the full-table scan estimate, the filter has not demonstrated the intended reduction. Diagnose the predicate before paying to execute it. The comparison is stronger evidence than the presence of a date condition in the SQL, because it tests what the planner can actually eliminate.
The parameterized query exception: when the dry run shows the full table and pruning is still working
A partition filter using @param can produce a full-table dry-run estimate even when execution prunes correctly. In this case, the parameter value becomes available only at execution. Without a value to compare against partition metadata, the estimate conservatively includes all partitions. The dry run and the eventual bill are answering different questions.
A large estimate followed by a much smaller billed scan does not, by itself, mean either system is wrong. For this parameterized case, treat the estimate as an upper bound. The limitation concerns when the filter value becomes available. It does not undermine the comparison for literal or constant-expression filters that the planner can resolve.
For parameterized queries, check total_bytes_billed in the completed job record in INFORMATION_SCHEMA.JOBS for the authoritative billed-byte result. The processed-byte field also shows how much data the query scanned. This preserves the distinction between what could be estimated before execution and what the query actually did once its parameter values were available.
Post-execution confirmation with INFORMATION_SCHEMA.JOBS
INFORMATION_SCHEMA.JOBS supplies the second instrument in the verification process. For a query with an effective partition filter, total_bytes_processed should be roughly consistent with the matching partitions. Start with the completed job of interest. Read its query text and processed-byte count. Include total_bytes_billed when checking the billed result of a parameterized query. These fields let the audit connect a scan measurement to the SQL that produced it.
To find past runs that may have scanned too much data, write a query against the region’s INFORMATION_SCHEMA.JOBS view. Select the job identifier, query text, creation time, and total_bytes_processed, with user information where useful for tracing the query. Restrict the results to completed query jobs from the last seven days and to scans above a chosen byte threshold. Sort by processed bytes in descending order. Under on-demand pricing, this brings the largest scans toward the top for investigation without assuming that every large scan is unjustified.
The same approach applies to dbt models. Pull processed-byte counts for each model’s jobs and flag models whose scans are close to full-table size even though they were meant to scan only some partitions. A historical audit can reveal regressions that a development-time check missed, including changes introduced by an updated macro or upstream schema.
Diagnosing stubborn pruning failures: the execution plan and common culprits
When the byte checks suggest a full scan but the predicate looks right, check the execution plan. In the console, open the completed job’s Execution details tab. Through the API, inspect queryPlan in the Jobs response. Look for table-scan stages and check whether their read operations have partition filters.
A filter that uses CURRENT_TIMESTAMP() needs a closer look when its value changes in a way that keeps the planner from resolving the predicate to a static partition range. Do not diagnose it from the function name alone. Use the dry-run comparison to check whether the estimate is still near full-table size with the filter in place.
In a condition such as WHERE DATE(created_at, timezone) >=..., a timezone that varies by row prevents the expression from defining a fixed partition range. Keep the local-time condition for its business meaning. Add a redundant UTC filter on the partition column with a one-day buffer, so the planner can restrict the scan while the local-time expression selects the intended records. The two predicates serve different purposes.
A dbt utility macro may look appropriate in Jinja while generating DATE(event_timestamp) around a TIMESTAMP partition column. Inspect the compiled SQL. The fix is to filter directly on the partition column without wrapping it. A fresh dry run then tests whether that change restores the expected reduction in scanned bytes.
Computed-date joins in MERGE statements need a target-side restriction. A join condition that uses DATE(src.event_time) relies on source values that are unknown until the join runs, so the planner has no constant target partition range. Add an explicit constant predicate on the target’s partition column. BI-generated SQL has a different trap. It may include the partition column in the SELECT list but omit it from WHERE, so inspect the query text in INFORMATION_SCHEMA.JOBS to distinguish a displayed date from an actual scan restriction.
The asymmetry between partition pruning and clustering in dry-run output
Partitioning and clustering reduce scanned bytes at different stages, which limits what a dry run can report. Partition pruning eliminates whole partitions at planning time, so its effect appears in the estimate. Clustering works later. Its block skipping happens during the scan, so the estimate can be higher than the bytes the query ends up processing. That gap is not evidence that the partition check was useless.
First compare the filtered and unfiltered estimates to check the partition contribution. Then inspect total_bytes_processed after execution to see the additional reduction from block skipping. The two readings belong to different phases.
This distinction also keeps the scope of the test clear. Storage layout and compute design affect different parts of what a query costs, and partition verification tests only one of those ways to cut costs. ObsessionDB is another managed service that uses compute-storage separation and serves reads through a cache mesh over object storage, so it may fit a workload whose costs no longer work well with the per-byte model. That workload decision is separate from checking whether a BigQuery filter works.
Making verification a repeatable habit: guardrails and CI integration
A repeatable workflow needs protections at the table, query, and pipeline levels. Set require_partition_filter on tables where unfiltered access should be rejected, and use maximum_bytes_billed as a query-level spending guardrail. The intended scan range still needs to be checked with both in place. Schedule a weekly INFORMATION_SCHEMA.JOBS audit to surface jobs whose processed bytes have crept back toward full-table size. This provides an ongoing check when schema changes or macro updates alter queries that once pruned correctly.
To catch regressions before deployment, embed the dry-run API in the SQL review pipeline. Submit each changed SQL file with dryRun set to true and gate the pull request on totalBytesProcessed staying within a defined threshold, allowing for the parameterized-query boundary. For dbt, test the compiled SQL before merging the model change into the production DAG, and fix unexpected full-table estimates before deployment. The loop now has three checkpoints: dry runs before the query runs, job audits after it runs, and CI checks with each relevant change.



