Request a demo

BigQuery cost query · Waste

Find unused BigQuery tables

This query finds tables older than 90 days that no query job has read in the last 90 days, with their size and monthly storage cost. They are the safest storage savings: archive, expire or delete them after checking with their owners.

Runs on INFORMATION_SCHEMA metadata only · Columns checked against the Google Cloud docs in November 2026

The query

WITH reads AS (
  SELECT DISTINCT t.project_id, t.dataset_id, t.table_id
  FROM `region-us`.INFORMATION_SCHEMA.JOBS AS j,
    UNNEST(j.referenced_tables) AS t
  WHERE j.creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 90 DAY)
)
SELECT
  s.table_schema                                        AS dataset,
  s.table_name,
  s.creation_time,
  s.storage_last_modified_time,
  ROUND(s.total_logical_bytes / POW(1024, 3), 1)        AS logical_gib,
  ROUND((s.active_logical_bytes * 0.02
       + s.long_term_logical_bytes * 0.01) / POW(1024, 3), 2) AS logical_usd_month
FROM `region-us`.INFORMATION_SCHEMA.TABLE_STORAGE AS s
LEFT JOIN reads AS r
  ON  r.project_id = s.project_id
  AND r.dataset_id = s.table_schema
  AND r.table_id   = s.table_name
WHERE r.table_id IS NULL
  AND NOT s.deleted
  AND s.creation_time < TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 90 DAY)
ORDER BY logical_usd_month DESC
LIMIT 100;

How it works

referenced_tables in JOBS lists every table a job read. Tables in TABLE_STORAGE that never appear there over 90 days have not been queried in that time. The age filter skips tables created recently, which haven't had the chance to be read.

Treat the result as a list of candidates, not a delete list. Some tables are read in ways JOBS doesn't record, and some are kept on purpose (audit, compliance, yearly reports). Setting a table expiration is a gentler first step than deleting.

Output columns

ColumnMeaning
storage_last_modified_timeLast time data was written. A table that is still being written but never read is a dead-end table.
logical_usd_monthMonthly cost under logical billing, the default.

Permissions and notes

Needs: Both of the above: bigquery.jobs.listAll for JOBS and bigquery.tables.get / bigquery.tables.list for TABLE_STORAGE (BigQuery Resource Viewer plus BigQuery Metadata Viewer).

  • This JOBS view only covers queries run in this project. Tables read from other projects need JOBS_BY_ORGANIZATION in the reads CTE.
  • Reads through the Storage Read API (Spark, Dataflow, some BI connectors), exports and copy jobs are not query reads and won't count as use.
  • Wildcard queries over sharded tables (events_*) and views can make tables look unused if your queries reach them in ways the list doesn't name; check before deleting.

Variations

Expire a table instead of deleting it

ALTER TABLE `project.dataset.old_table`
SET OPTIONS (expiration_timestamp = TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 30 DAY));

FAQ

Can I recover a table I deleted by mistake?

Within the time travel window (7 days by default) you can restore it, for example with a copy using a snapshot time. After that, only fail-safe recovery through Google Cloud support remains, for another 7 days.

Why not just rely on long-term storage pricing?

Long-term storage halves the price of a table nobody uses; deleting it removes the cost. For large estates the difference adds up.

All BigQuery cost queries · Data FinOps playbook · Pricing calculator

Cut BigQuery spend without guessing

Masthead attributes compute and storage cost to every project, user, pipeline and table, finds unused and dead-end tables, and shows where editions or on-demand pricing is cheaper. Mnemonic cut its BigQuery compute cost by 20% within 24 hours of onboarding.