The short answer
BigQuery on-demand pricing charges $6.25 per terabyte of data scanned. Without architectural guardrails, an accidental query scanning multi-terabyte tables can incur hundreds of dollars in seconds.
BigQuery query cost controls
Data teams implement several native controls to protect against runaway query costs:
- Maximum bytes billed: Set the
maximum_bytes_billedlimit in query job options or custom scripts. If a query estimated scan size exceeds this limit, BigQuery fails the job before scanning any data. - Require filter: Enable the
require_partition_filter = truetable setting on large partitioned tables. Queries against the table fail immediately if the query omits a partition filter in theWHEREclause. - Dry run estimations: Run queries with the
dry_run = Trueflag in client code to determine exact bytes scanned without running the query or incurring costs. - Editions and reservations: Switch from on-demand billing to BigQuery Editions (Standard or Enterprise) with autoscaling slot reservations for predictable baseline monthly expenses.
BigQuery Table Setting: require_partition_filter = true (Forces WHERE clause)
Client Query Options: maximum_bytes_billed = 50 GB (Rejects giant scans)
Dry Run Verification: dry_run = True (Calculates cost with $0 spent)
Cloud Storage Autoclass: Auto-moves idle objects to Nearline / ColdlineStorage tiering with Autoclass
Cloud Storage allows teams to enable Autoclass, an automated feature that transitions objects to Nearline, Coldline, and Archive classes based on access history without writing custom lifecycle rules.