Columns you never needed

A query often reads columns it does not need. Finding them is the quickest way to cut a bill.

How it works

A query pays for the columns its result really depends on. An outermost SELECT * depends on all of them, and a nested column such as defects is one of the largest. To lower the estimate, depend on fewer columns and read fewer months.

Common mistake

Taking a column out of the final SELECT does not lower the estimate while the same column still appears in a WHERE, JOIN or ORDER BY.

Worked example

SELECT vehicle_id, test_result
FROM `learn.mot.fact_mot_test`
WHERE completed_date = '2024-06-12'
  AND make = 'AUDI'

The result depends on four columns: vehicle_id, test_result, completed_date and make.

All four are read for the June partition, even though completed_date and make are not returned.

All BigQuery lessons