Özer Cem KELAHMETKELAHMET
AI Simulations · Data management

BigQuery bytes scanned: how partition pruning and column choice set the cost of a query

A BigQuery on-demand query is billed for the bytes it reads, not the rows it returns. Pick a date window, switch partition pruning on and off, choose how many columns you select and watch the bytes, the cost per run and the monthly bill of an hourly dashboard change.

Download Markdown

Interactive simulation. It needs JavaScript; the text below explains what it shows.

What you are looking at

The table in the simulation is a web events table split into 28 daily partitions, one per day. Each row of the data grid is one partition and its size in GiB. The sizes are illustrative but shaped like real traffic: busy weekdays, quiet weekends and slow growth, about 1,289 GiB in total.

A dashboard runs the same query every hour. The query asks for the last seven days and reads a handful of columns. In BigQuery on-demand pricing you pay for the bytes the query processes, so two things decide the bill: which partitions are read and which columns are read.

The controls let you change the date window, whether the filter actually prunes partitions, the share of each row's bytes that sits in the columns you select (100% is SELECT *), how often the query runs and the price per TiB. The bars show how many GiB each partition contributes. The chart shows the cost of one run against the number of days in the filter, with and without pruning, and the vertical line marks how many partitions the current query reads.

Think of the table as a library with one shelf per day and one drawer per column. Pruning means you walk only to the shelves for the days you asked about. Column selection means you open only the drawers you need. You pay for every drawer you open, however few lines you copy out.

The algorithm

  1. Find the partitions to read. A partition for day d is inside the window when d from ≤ d ≤ d to. If the WHERE clause compares the partitioning column with constants, BigQuery skips every other partition. If it does not (a subquery, an unsupported function, an OR with another column), every partition is read.
  2. Read only the selected columns. BigQuery stores each column separately, so the bytes read from a partition are its size times the share of bytes in the selected columns. A LIMIT does not change this for a non-clustered table.
  3. Add up the bytes. The bytes processed are the sum over the partitions that are read.
  4. Apply the billing rules. Charges are rounded up to the nearest MB, with a minimum of 10 MB per table referenced and per query.
  5. Price it. Cost per run is the billed bytes in TiB times the on-demand price, $6.25 per TiB, after the first free TiB each month.
  6. Multiply by the schedule. A query that runs 24 times a day runs 720 times in 30 days.

Worked example (the default settings). The window is days 22 to 28, so 7 partitions are read and 21 are skipped. Those 7 days hold 338.0 GiB. The query selects 15% of each row's bytes, so it processes 338.0 × 0.15 = 50.7 GiB. At $6.25 per TiB one run costs 50.7 / 1024 × 6.25 = $0.31. Running every hour, the dashboard processes 50.7 × 24 × 30 / 1024 = 35.65 TiB in 30 days, which is $222.80 before the free TiB.

Now set pruning to 0. The same seven-day query reads all 28 partitions: 1,288.7 × 0.15 = 193.3 GiB, $1.18 per run and $849.48 a month, almost four times as much for the same answer. A SELECT * over the whole table with no pruning reads 1,288.7 GiB and costs $7.87 per run.

Things to try

  • Set pruning to 0 and leave everything else alone. The cost per run jumps from $0.31 to $1.18, because a filter that BigQuery cannot use for pruning reads every partition.
  • Set the share of row bytes to 100% (SELECT *) with pruning on. The seven days now cost $2.06 per run: column choice matters as much as the date filter.
  • Narrow the window to a single day (from 28 to 28). The run processes 5.3 GiB and costs about $0.03, and the 10 MB minimum is still far away.
  • Raise runs per day from 24 to 96 (a refresh every 15 minutes). The monthly bill grows four times, to $891.21, while each run costs the same.
  • Paste the real partition sizes of one of your tables from INFORMATION_SCHEMA.PARTITIONS (total_logical_bytes divided by 2^30) and check what your own dashboard query costs.

How it works in real systems

BigQuery estimates bytes before running a query: a dry run, or the estimate in the console, shows the bytes processed. Google notes that this estimate is an upper bound and can be higher than the bytes actually billed after the query runs. The maximum bytes billed setting makes a query fail without a charge when its estimate is above a limit, and the table option require_partition_filter rejects queries that have no usable filter on the partitioning column. Both are cheap protection against a dashboard that suddenly reads the whole table.

Pruning only works when the filter can be decided before the scan: compare the partitioning column with a constant expression, keep the column on its own side of the comparison, and combine other conditions with AND, not OR. Logical bytes per column depend on the data type, so long text columns are usually the expensive ones. For workloads that run all day, capacity pricing (slots) can be cheaper than paying per byte; the comparison is the same idea as sizing a Snowflake warehouse. For a longer explanation of partitioning and clustering, read BigQuery bytes billed, and see the BigQuery tool page. Partition design upstream is part of the medallion pipeline too.

Sources

Last updated Nov 24, 2026
Type to search.
    ↑↓ navigate↵ open