BigQuery cost query · Storage
Find tables paying for time travel and fail-safe storage
This query finds the tables with the most time-travel and fail-safe bytes, which physical storage billing charges at the active rate. Tables rebuilt every day are the usual culprits; shortening the time travel window or loading incrementally fixes them.
The query
SELECT
table_schema AS dataset,
table_name,
deleted,
ROUND(time_travel_physical_bytes / POW(1024, 3), 1) AS time_travel_gib,
ROUND(fail_safe_physical_bytes / POW(1024, 3), 1) AS fail_safe_gib,
ROUND((time_travel_physical_bytes + fail_safe_physical_bytes)
/ POW(1024, 3) * 0.04, 2) AS usd_month_if_physical
FROM `region-us`.INFORMATION_SCHEMA.TABLE_STORAGE
WHERE time_travel_physical_bytes + fail_safe_physical_bytes > 0
ORDER BY usd_month_if_physical DESC
LIMIT 100;How it works
Every change to a table keeps the replaced data for the time travel window (7 days by default, configurable from 2 to 7) and then for a fixed 7-day fail-safe period. Under logical billing that is free; under physical billing it is charged at the active physical rate. A 500 GiB table replaced every day can carry many times its own size in time-travel and fail-safe bytes.
Two fixes: shorten the time travel window on datasets that don't need a week of history, and stop rebuilding whole tables when only recent data changes (load or overwrite only new partitions).
Output columns
| Column | Meaning |
|---|---|
deleted | TRUE for deleted tables, which still pay for their time travel and fail-safe bytes under physical billing. |
usd_month_if_physical | Monthly cost of those bytes at the US active physical rate; zero extra under logical billing. |
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).
- Fail-safe (7 days) can't be shortened; only time travel can.
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.
Variations
Shorten the time travel window to two days
ALTER SCHEMA `project.dataset`
SET OPTIONS (max_time_travel_hours = 48);FAQ
What does time travel cost under logical billing?
Nothing extra: logical billing includes time travel and fail-safe in the per-GiB price.
What values can the time travel window take?
Multiples of 24 hours from 48 (2 days) to 168 (7 days), set per dataset with max_time_travel_hours, or as a project default.
Related
All BigQuery cost queries · Data FinOps playbook · Pricing calculator
