What a query costs

You want to know what a query will cost before you run it. BigQuery gives you that number up front, and it is easy to read once you know what it counts.

How it works

BigQuery stores each column of a table separately. A query reads the columns its result depends on, from the partitions its date filter allows, and the on-demand price follows the bytes it processes. The editor shows an estimate of that number before you run anything.

Common mistake

A fast query can still read a lot of data, and a slow one can read very little. The clock says little about the bill, so compare byte estimates before you run.

Worked example

SELECT COUNT(DISTINCT vehicle_id) AS vehicles
FROM `learn.mot.fact_mot_test`
WHERE completed_date BETWEEN '2024-03-01' AND '2024-03-31'

The query names two columns, vehicle_id and completed_date.

The filter selects the March 2024 partition, so those two columns of that one month are what the estimate counts.

All BigQuery lessons