Data FinOps
BigQuery cost queries
Copy, paste, run. Each query reads INFORMATION_SCHEMA metadata only, answers one cost question, and comes with what to do about the result. Together they are a Data FinOps toolkit for BigQuery.
No query matches. See the INFORMATION_SCHEMA.JOBS reference.
Where the money goes
Find the queries, users, projects and days that make up the bill.
- BigQuery cost by project across the organizationThis query ranks every project in the organization by bytes billed, on-demand cost estimate and slot-hours over the last 30 days, from one INFORMATION_SCHEMA view.
- BigQuery cost by user and service accountThis query adds up bytes billed, an on-demand cost estimate and slot-hours per user and service account over the last 30 days.
- Daily BigQuery cost trend and spike detectionThis query returns BigQuery compute per day for the last 90 days (bytes billed, on-demand cost estimate, slot-hours) and a variation flags days that cost more than twice the previous week's average.
- Find the most expensive queries in BigQueryThis query lists the BigQuery jobs that billed the most bytes in the last 30 days, with an on-demand cost estimate, slot-hours and the start of the SQL.
- Which BigQuery tables drive query costThis query ranks tables by the bytes billed of the queries that read them over the last 30 days, with an even split for queries that read several tables.
Cost attribution
Split compute cost by label, pipeline, dbt model and BI tool, so every dollar has an owner.
- BigQuery cost by label: team, product or pipelineThis query splits BigQuery compute by the value of a job label, such as team or cost center, and shows how much spend has no label at all.
- BigQuery cost of Looker Studio dashboardsThis query finds the BigQuery jobs Looker Studio runs, groups them by data source and shows their on-demand cost and cache hit rate over the last 30 days.
- BigQuery cost per Airflow DAG and taskThis query uses the airflow-dag and airflow-task labels that Airflow's Google provider adds to BigQuery jobs to rank DAGs and tasks by on-demand cost and slot-hours over the last 30 days, on Cloud Composer or any other Airflow.
- BigQuery cost per dbt modelThis query attributes BigQuery compute to dbt models by reading the JSON comment dbt prepends to every query, then ranks models by on-demand cost, slot-hours and run time over the last 30 days.
Slots and billing model
Measure slot usage and decide between on-demand and editions per workload.
- BigQuery slot usage by hourThis query turns INFORMATION_SCHEMA.JOBS_TIMELINE into the average number of slots your jobs used in each hour of the last week.
- On-demand vs editions: which is cheaper per projectThis query compares what each project's queries cost on-demand with what the same slot-hours would cost on Standard and Enterprise editions, using 30 days of INFORMATION_SCHEMA data, and adds the GiB scanned per slot-hour that decides the answer.
- Peak and p95 BigQuery slot usageThis query computes slots in use for every second of the last week from JOBS_TIMELINE, then reports the average, 95th percentile and peak per hour.
Storage
See what each table and dataset costs to keep, and which billing model is cheaper.
- BigQuery storage cost per tableThis 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.
- Find tables paying for time travel and fail-safe storageThis query finds the tables with the most time-travel and fail-safe bytes, which physical storage billing charges at the active rate.
- Logical vs physical storage billing: which datasets to switchThis query computes each dataset's monthly storage cost under logical and physical billing with Google's own forecast formula, and the saving from switching.
Waste
Unused tables, dead-end tables, failed jobs and repeated queries: spend that buys nothing.
- Failed BigQuery jobs and the slots they wasteThis query groups the last 30 days of failed BigQuery jobs by error reason, with how many failed, who ran them and the slot-hours they used before failing.
- Find dead-end tables: written but never readThis query finds tables that jobs wrote to in the last 30 days but no query read, and what building them cost.
- Find repeated BigQuery queries and cache missesThis query finds queries that run over and over with the same shape, with how often they ran, how often the result cache answered them and what they cost.
- Find SELECT * queries that scan whole tablesThis query finds the most expensive queries that start with SELECT FROM in the last 30 days, grouped by principal.
- Find unused BigQuery tablesThis 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.
