BigQuery Cost Estimation
16 min
Data Warehousing's columnar-storage module showed why columnar
storage makes column-selective queries so much cheaper in terms of
BYTES READ. BigQuery's real pricing takes that idea directly to your
bill: on-demand queries are billed per terabyte of data SCANNED, at a
flat rate — meaning the exact columnar-storage savings from that
earlier module translate directly into dollars, not just abstract I/O
efficiency.
def query_cost(bytes_scanned, price_per_tb=6.25):
tb_scanned = bytes_scanned / (1024 ** 4)
return round(tb_scanned * price_per_tb, 4)
This is the exact real-world consequence of Data Warehousing's columnar-storage lesson: if a query only needs 2 of a table's 50 columns, a columnar engine like BigQuery only scans (and bills for) those 2 columns -- selecting fewer columns isn't just a performance habit, it's a direct cost lever.
Write `query_cost(bytes_scanned, price_per_tb=6.25)`: convert `bytes_scanned` to terabytes (divide by `1024**4`) and multiply by `price_per_tb`. Round to 4 decimal places.
BigQuery's on-demand pricing charges by BYTES SCANNED, not by query runtime or result size. What does that mean for how you should write queries to control cost?
You can estimate BigQuery's on-demand query cost from bytes scanned, and understand why minimizing scanned data (not just query complexity) is the real cost lever.