BigQuery cost query · Storage
BigQuery storage cost per table
This query lists the tables that cost the most to store, with logical and physical size and the monthly cost under each billing model, from INFORMATION_SCHEMA.TABLE_STORAGE. It finds the few tables that make up most of the storage bill.
The query
SELECT
table_schema AS dataset,
table_name,
ROUND(total_logical_bytes / POW(1024, 3), 1) AS logical_gib,
ROUND(total_physical_bytes / POW(1024, 3), 1) AS physical_gib,
ROUND((active_logical_bytes * 0.02
+ long_term_logical_bytes * 0.01) / POW(1024, 3), 2) AS logical_usd_month,
ROUND(((active_physical_bytes + fail_safe_physical_bytes) * 0.04
+ long_term_physical_bytes * 0.02) / POW(1024, 3), 2) AS physical_usd_month,
storage_last_modified_time
FROM `region-us`.INFORMATION_SCHEMA.TABLE_STORAGE
WHERE NOT deleted
ORDER BY logical_usd_month DESC
LIMIT 100;How it works
TABLE_STORAGE reports every table's bytes split into active (changed in the last 90 days) and long-term, for both logical (uncompressed) and physical (compressed) sizes. Which of the two cost columns applies depends on the dataset's storage billing model; logical is the default.
Large tables with an old storage_last_modified_time are already on the cheaper long-term rate; large tables modified daily stay at the active rate. If nobody reads them, check unused tables before paying for either.
Output columns
| Column | Meaning |
|---|---|
logical_usd_month | Monthly cost under logical (uncompressed) billing. |
physical_usd_month | Monthly cost under physical (compressed) billing, including fail-safe. |
storage_last_modified_time | Last time the table's data changed. |
Permissions and notes
Needs: bigquery.tables.get and bigquery.tables.list on the project, for example through the BigQuery Metadata Viewer role (roles/bigquery.metadataViewer).
- Prices are US multi-region list prices per GiB-month: active logical $0.02, long-term logical $0.01, active physical $0.04, long-term physical $0.02. EU physical is $0.044 and $0.022; see BigQuery pricing.
active_physical_bytesalready includes time-travel bytes, and fail-safe bytes are billed on top. The physical formula here is the one Google uses in its own storage forecast.- Deleted tables are excluded; under physical billing they keep costing until their time travel and fail-safe periods end (
WHERE deletedshows them).
Variations
Storage cost per dataset
SELECT
table_schema AS dataset,
COUNT(*) AS tables,
ROUND(SUM(active_logical_bytes * 0.02 + long_term_logical_bytes * 0.01) / POW(1024, 3), 2) AS logical_usd_month
FROM `region-us`.INFORMATION_SCHEMA.TABLE_STORAGE
WHERE NOT deleted
GROUP BY dataset
ORDER BY logical_usd_month DESC;FAQ
Why is a table I never change still billed at the active rate?
Each partition is aged separately, and loads, DML, streaming and CREATE OR REPLACE reset the 90-day clock. A table rewritten daily never reaches long-term storage.
Is the first 10 GiB free?
Yes, the first 10 GiB of storage each month is free per billing account. At table level it doesn't change the ranking.
Related
All BigQuery cost queries · Data FinOps playbook · Pricing calculator
