BigQuery cost query · Storage
Logical vs physical storage billing: which datasets to switch
This query computes each dataset's monthly storage cost under logical and physical billing with Google's own forecast formula, and the saving from switching. Physical billing usually wins for well-compressed data that doesn't churn.
The query
SELECT
table_schema AS dataset,
ROUND(SUM(active_logical_bytes * 0.02 + long_term_logical_bytes * 0.01) / POW(1024, 3), 2) AS logical_usd_month,
ROUND(SUM((active_physical_bytes + fail_safe_physical_bytes) * 0.04
+ long_term_physical_bytes * 0.02) / POW(1024, 3), 2) AS physical_usd_month,
ROUND(SAFE_DIVIDE(SUM(total_logical_bytes), SUM(total_physical_bytes)), 1) AS compression_ratio,
ROUND(SUM(time_travel_physical_bytes + fail_safe_physical_bytes) / POW(1024, 3), 1) AS tt_and_fail_safe_gib
FROM `region-us`.INFORMATION_SCHEMA.TABLE_STORAGE
WHERE total_physical_bytes + fail_safe_physical_bytes > 0
GROUP BY dataset
ORDER BY logical_usd_month - physical_usd_month DESC;How it works
Physical billing costs about twice as much per GiB but charges for compressed bytes, plus time travel and fail-safe. Logical billing charges for uncompressed bytes and includes time travel and fail-safe. So physical wins when compression is better than about 2:1 and the data doesn't churn much: tables that are rewritten often build up time-travel and fail-safe bytes that only physical billing charges for.
The model is a dataset option. Switching takes 24 hours to apply and you can't switch the same dataset again for 14 days, so check a full month of the numbers first.
Output columns
| Column | Meaning |
|---|---|
compression_ratio | Logical bytes per physical byte. Above about 2, physical billing tends to be cheaper. |
tt_and_fail_safe_gib | Time-travel and fail-safe bytes, which physical billing charges at the active rate. |
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.- Physical billing can't be enabled in a region where the organization still has legacy flat-rate commitments.
Variations
Switch a dataset to physical billing
ALTER SCHEMA `project.dataset`
SET OPTIONS (storage_billing_model = 'PHYSICAL');FAQ
Does physical billing change query performance or cost?
No. It changes only how storage is billed; queries are billed the same way.
Can I switch back?
Yes, after 14 days. Each change takes 24 hours to take effect.
Related
All BigQuery cost queries · Data FinOps playbook · Pricing calculator
