Skip to content
Finitizer

BigQuery Query Fix List

See which of your costliest BigQuery queries to fix first, what each costs now and what a fix could save.

Google CloudReads your own dataBring a fileVersion 1.0
New here? Try the Training: one worked example, step by step, with a PDF to keep.

Learn more

BigQuery Query Fix List

What this free tool does for you

See which of your costliest BigQuery queries to fix first, what each costs now and the most a fix could save.

How to use it

  1. Click Try it with sample data to see a finished list before you run anything.
  2. Pick the Location your data is in. It sets the queries and the prices.
  3. Click Copy query, run it in BigQuery and load the result. Queries 2 and 3 are optional and add checks.
  4. Click Make the fix list. Shapes to fix come first, costliest first.
  5. Open a shape for its findings and its SQL, then Download the list to share it.

Good to know

  • Not a sum. Fixes overlap, so each shape shows its single largest figure, never findings added together.
  • Private. Query text is read in this browser tab and never sent, not even for a review.

Not sure where to get the data? .

Before you start: what to have readyShow
  • The project the queries ran in. You need BigQuery Job User and BigQuery Resource Viewer on it. The organization view has no query text.
  • The location your datasets live in. INFORMATION_SCHEMA is regional, so the wrong location returns nothing rather than an error. It also sets the prices.
  • Thirty days of history. The queries read the last 30 complete UTC days.

See a list before you run anything. The sample is made-up results in the same columns as the real queries.

This changes the queries and the prices. US multi-region list prices: $6.25 per TiB on demand, and $0.06 a slot hour for Enterprise pay as you go, used only to rank queries that ran on a reservation. In USD, read from Google’s pricing page on 2026-11-07. Run them in the project whose queries you want checked, once per location.

1. Your costliest query shapes

The top 100 shapes by on-demand bytes and the top 100 by slot time, over the last 30 complete UTC days, each with the text of its costliest run, so the SQL itself can be checked. A shape is BigQuery’s hash of a query with its literals removed. The text can hold values from your data: it is read in this browser and never sent.

-- Finitizer BigQuery Query Fix List, query 1: your costliest query shapes.
-- A shape is BigQuery's hash of a query with literals and comments removed, so
-- the same report run with different dates is one shape. Lists the top 100 by
-- on-demand bytes billed and the top 100 by slot time (up to 200 rows), with
-- counts, bytes, slot time, cache use, the tables read and the text of each
-- shape's costliest run, cut at 30,000 characters.
-- Query text can hold values from your data. The page reads it in your browser.
-- It reads the query column, so it bills more than a totals-only query: check
-- the estimate in the console before you run it.
-- Window: the last 30 complete UTC days. Run it unchanged, in the project the
-- queries ran in (the organization view has no query text).
WITH jobs AS (
  SELECT
    query_info.query_hashes.normalized_literals                AS pattern,
    TO_HEX(MD5(query))                                         AS text_hash,
    query,
    statement_type,
    IFNULL(cache_hit, FALSE)                                   AS cached,
    (error_result IS NOT NULL AND IFNULL(error_result.reason, '') != 'stopped') AS failed,
    reservation_id,
    user_email,
    creation_time,
    IFNULL(total_bytes_billed, 0)                              AS bytes_billed,
    -- What on demand charges: no failed runs, built-in BigQuery ML training at 50 times.
    IF((error_result IS NULL OR error_result.reason = 'stopped'), IFNULL(total_bytes_billed, 0) * IF(statement_type = 'CREATE_MODEL' AND ml_statistics.model_type IN ('LINEAR_REGRESSION', 'LOGISTIC_REGRESSION', 'KMEANS', 'MATRIX_FACTORIZATION', 'PCA', 'ARIMA', 'ARIMA_PLUS', 'ARIMA_PLUS_XREG', 'CONTRIBUTION_ANALYSIS', 'TRANSFORM_ONLY'), 50, 1), 0) AS charged_bytes,
    -- Processed on the same terms, so billed less processed is the 10 MB minimum alone.
    IF((error_result IS NULL OR error_result.reason = 'stopped'), IFNULL(total_bytes_processed, 0) * IF(statement_type = 'CREATE_MODEL' AND ml_statistics.model_type IN ('LINEAR_REGRESSION', 'LOGISTIC_REGRESSION', 'KMEANS', 'MATRIX_FACTORIZATION', 'PCA', 'ARIMA', 'ARIMA_PLUS', 'ARIMA_PLUS_XREG', 'CONTRIBUTION_ANALYSIS', 'TRANSFORM_ONLY'), 50, 1), 0) AS bytes_processed,
    IFNULL(total_slot_ms, 0)                                   AS slot_ms,
    destination_table.dataset_id IS NOT NULL
      AND NOT STARTS_WITH(destination_table.dataset_id, '_')   AS named_destination,
    referenced_tables
  FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
  WHERE creation_time >= TIMESTAMP_SUB(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY), INTERVAL 30 DAY)
    AND creation_time < TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY)
    AND job_type = 'QUERY'
    AND (statement_type != 'SCRIPT' OR statement_type IS NULL)
),
marked AS (
  -- The same user's previous run of the same exact text, if any.
  SELECT
    *,
    LAG(creation_time) OVER (PARTITION BY text_hash, user_email ORDER BY creation_time) AS previous_same
  FROM jobs
),
texts AS (
  -- Each exact text, tied to the shape BigQuery hashed it as on any run.
  SELECT
    text_hash,
    ARRAY_AGG(pattern IGNORE NULLS LIMIT 1)[SAFE_OFFSET(0)]    AS shape
  FROM jobs
  WHERE text_hash IS NOT NULL
  GROUP BY text_hash
),
runs AS (
  -- A run keeps its own hash; a run with none takes its text's. A repeat is
  -- a run of a text the same user ran in the 24 hours before.
  SELECT
    m.*,
    IFNULL(m.pattern, t.shape)                                 AS shape,
    m.text_hash IS NOT NULL
      AND m.previous_same IS NOT NULL
      AND m.creation_time < TIMESTAMP_ADD(m.previous_same, INTERVAL 24 HOUR) AS repeat_24h
  FROM marked m
  LEFT JOIN texts t ON t.text_hash = m.text_hash
),
totals AS (
  SELECT
    COUNT(DISTINCT shape)                                      AS shapes_total,
    COUNT(*)                                                   AS all_runs,
    SUM(IF(reservation_id IS NULL, charged_bytes, 0))          AS all_on_demand_bytes_billed,
    SUM(slot_ms)                                               AS all_slot_ms,
    COUNTIF(shape IS NULL)                                     AS unattributed_runs,
    SUM(IF(shape IS NULL AND reservation_id IS NULL, charged_bytes, 0))
                                                               AS unattributed_on_demand_bytes_billed,
    SUM(IF(shape IS NULL, slot_ms, 0))                         AS unattributed_slot_ms
  FROM runs
),
shapes AS (
  SELECT
    shape                                                      AS pattern,
    COUNT(*)                                                   AS runs,
    COUNTIF(cached)                                            AS cached_runs,
    COUNTIF(failed)                                            AS failed_runs,
    COUNTIF(reservation_id IS NOT NULL)                        AS reserved_runs,
    COUNTIF(named_destination)                                 AS named_destination_runs,
    COUNT(DISTINCT user_email)                                 AS users,
    SUM(IF(reservation_id IS NULL, charged_bytes, 0))          AS on_demand_bytes_billed,
    SUM(IF(reservation_id IS NULL AND NOT cached, bytes_processed, 0))
                                                               AS on_demand_bytes_processed,
    SUM(bytes_billed)                                          AS bytes_billed,
    SUM(slot_ms)                                               AS slot_ms,
    SUM(IF(reservation_id IS NOT NULL, slot_ms, 0))            AS reserved_slot_ms,
    SUM(IF(failed AND reservation_id IS NOT NULL, slot_ms, 0)) AS failed_reserved_slot_ms,
    COUNT(DISTINCT text_hash)                                  AS texts,
    COUNTIF(repeat_24h)                                        AS repeated_runs,
    COUNTIF(repeat_24h AND NOT cached AND NOT failed)          AS uncached_repeat_runs,
    SUM(IF(repeat_24h AND NOT cached AND NOT failed AND reservation_id IS NULL, charged_bytes, 0))
                                                               AS uncached_repeat_on_demand_bytes,
    MIN(creation_time)                                         AS first_run,
    MAX(creation_time)                                         AS last_run,
    ARRAY_AGG(STRUCT(query, statement_type, bytes_billed, slot_ms, referenced_tables)
      ORDER BY bytes_billed DESC, slot_ms DESC LIMIT 1)[OFFSET(0)] AS costliest
  FROM runs
  WHERE shape IS NOT NULL
  GROUP BY shape
),
ranked AS (
  SELECT
    s.*,
    ROW_NUMBER() OVER (ORDER BY s.on_demand_bytes_billed DESC, s.pattern) AS rank_bytes,
    ROW_NUMBER() OVER (ORDER BY s.slot_ms DESC, s.pattern)     AS rank_slots
  FROM shapes s
)
SELECT
  r.pattern,
  r.costliest.statement_type                                   AS statement_type,
  r.runs,
  r.cached_runs,
  r.failed_runs,
  r.reserved_runs,
  r.named_destination_runs,
  r.users,
  r.texts,
  r.repeated_runs,
  r.uncached_repeat_runs,
  r.uncached_repeat_on_demand_bytes,
  r.on_demand_bytes_billed,
  r.on_demand_bytes_processed,
  r.bytes_billed,
  r.slot_ms,
  r.reserved_slot_ms,
  r.failed_reserved_slot_ms,
  r.first_run,
  r.last_run,
  r.costliest.bytes_billed                                     AS sample_bytes_billed,
  r.costliest.slot_ms                                          AS sample_slot_ms,
  ARRAY_TO_STRING(ARRAY(
    SELECT DISTINCT CONCAT(t.project_id, '.', t.dataset_id, '.', t.table_id)
    FROM UNNEST(r.costliest.referenced_tables) t
    ORDER BY 1), ', ')                                         AS tables,
  LENGTH(r.costliest.query)                                    AS query_length,
  SUBSTR(r.costliest.query, 1, 30000)                        AS query,
  t.shapes_total,
  t.all_runs,
  t.all_on_demand_bytes_billed,
  t.all_slot_ms,
  t.unattributed_runs,
  t.unattributed_on_demand_bytes_billed,
  t.unattributed_slot_ms,
  COUNT(*) OVER ()                                             AS result_rows,
  TIMESTAMP_SUB(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY), INTERVAL 30 DAY) AS window_start,
  TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY)                     AS window_end,
  'us'                                                AS location,
  '2026-12-01'                                         AS query_version
FROM ranked r
CROSS JOIN totals t
WHERE r.rank_bytes <= 100 OR r.rank_slots <= 100
ORDER BY r.on_demand_bytes_billed DESC, r.slot_ms DESC;
Not added yet

2. The tables those queries read (optional)

Columns, partitioning, clustering and size of every table a query read. With it, the list checks partition filters and flags large tables read whole. Table and column names only: no data rows.

-- Finitizer BigQuery Query Fix List, query 2 (optional): the tables your queries read.
-- Column names, types, partitioning, clustering and table sizes for every table
-- a query read in the window. No data rows and no query text.
-- result_rows lets the page tell a whole result from one console page.
-- Covers the tables of the project you run it in that its own queries read.
-- Window: the last 30 complete UTC days.
WITH read_tables AS (
  SELECT DISTINCT t.dataset_id, t.table_id
  FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT j,
    UNNEST(j.referenced_tables) t
  WHERE j.creation_time >= TIMESTAMP_SUB(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY), INTERVAL 30 DAY)
    AND j.creation_time < TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY)
    AND j.job_type = 'QUERY'
    AND t.project_id = j.project_id
)
SELECT
  c.table_schema,
  c.table_name,
  c.column_name,
  c.data_type,
  c.is_partitioning_column,
  c.clustering_ordinal_position,
  tb.table_type,
  -- The partition grain, read from the table's DDL when it shows one.
  REGEXP_EXTRACT(tb.ddl, r'PARTITION BY ([^\n;]+)')           AS partition_by,
  IFNULL(LOWER(o.option_value) = 'true', FALSE)               AS require_partition_filter,
  s.total_rows,
  s.total_logical_bytes,
  s.total_partitions,
  -- The project these tables are in, so a table of the same name in another project is not matched.
  @@project_id                                                AS run_in_project,
  COUNT(*) OVER ()                                             AS result_rows,
  TIMESTAMP_SUB(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY), INTERVAL 30 DAY) AS window_start,
  TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY)                     AS window_end,
  'us'                                                AS location,
  '2026-12-01'                                         AS query_version
FROM `region-us`.INFORMATION_SCHEMA.COLUMNS c
JOIN read_tables r
  ON r.dataset_id = c.table_schema AND r.table_id = c.table_name
JOIN `region-us`.INFORMATION_SCHEMA.TABLES tb
  ON tb.table_schema = c.table_schema AND tb.table_name = c.table_name
LEFT JOIN `region-us`.INFORMATION_SCHEMA.TABLE_OPTIONS o
  ON o.table_schema = c.table_schema AND o.table_name = c.table_name
  AND o.option_name = 'require_partition_filter'
LEFT JOIN `region-us`.INFORMATION_SCHEMA.TABLE_STORAGE s
  ON s.table_schema = c.table_schema AND s.table_name = c.table_name
ORDER BY c.table_schema, c.table_name, c.ordinal_position;
Optional

3. Google’s recommendations (optional)

Google’s own partitioning and clustering recommendations for this project, with the slot time Google expects each to save. Needs the partition and cluster recommendations viewer role.

-- Finitizer BigQuery Query Fix List, query 3 (optional): Google's recommendations.
-- Google's own partitioning and clustering recommendations for tables in this
-- project, with the slot time and bytes Google expects each to save a month.
-- Needs the partition and cluster recommendations viewer role. The view is in
-- Preview. No query text. The page keeps only the open (ACTIVE) ones.
SELECT
  recommender,
  subtype,
  TO_JSON_STRING(target_resources)                             AS target_resources,
  description,
  state,
  priority,
  LAX_INT64(additional_details.overview.bytesSavedMonthly)     AS bytes_saved_monthly,
  LAX_INT64(additional_details.overview.slotMsSavedMonthly)    AS slot_ms_saved_monthly,
  last_updated_time,
  COUNT(*) OVER ()                                             AS result_rows,
  CURRENT_TIMESTAMP()                                          AS snapshot_at,
  'us'                                                AS location,
  '2026-12-01'                                         AS query_version
FROM `region-us`.INFORMATION_SCHEMA.RECOMMENDATIONS
WHERE recommender = 'google.bigquery.table.PartitionClusterRecommender'
ORDER BY last_updated_time DESC;
Optional
Each file goes to the right step by its columns.
Your results are read in this browser and never leave it.

Prices verified 7 Nov 2026. Public list prices in USD for 48 BigQuery locations, before any discount you have negotiated.

Want this done on your real bill?

BigQuery Cost Audit: We find the queries, tables and slots driving your BigQuery bill and fix them without slowing anyone down. From $2,500, fixed. Nothing paid upfront.

See the service

Questions

Does it need access to my Google Cloud account?

No. You run read-only INFORMATION_SCHEMA queries in your own console and load the results here. The list is worked out in your browser.

Is my query text sent anywhere?

No. Query text can hold values from your data, so it is read in this browser tab and never sent, not even for a review. Usage statistics record that a file was read and a size band, never anything in it.

What permissions do the queries need?

BigQuery Job User and BigQuery Resource Viewer on the project the queries ran in, to read its job history. Query 2 also needs Metadata Viewer, and query 3 the partition and cluster recommendations viewer role.

What does it check?

Each shape's SQL goes through the same checks as the BigQuery Query Cost Calculator: SELECT *, missing partition filters, filters that do not prune and more. Its run history adds repeats the cache did not serve, bytes billed for the 10 MB minimum, failed runs and Google's own recommendations.

What does "most it could save" mean?

For each shape, the largest single on-demand figure among its findings, capped at what the shape costs. Fixes overlap, since the cache and a partition filter can save the same bytes, so they are never added together.

How does it treat reservations?

Reserved work is never priced from bytes. Its slot time is valued at the edition's pay as you go rate, only to rank it. A reservation bills its slots whether a query uses them or not, so a fix frees capacity first.

How much do the queries cost to run?

INFORMATION_SCHEMA queries bill like any query. Query 1 reads query text, so it reads more than a totals-only query, and a busy project reads more. The console shows an estimate before you run it.

Why is a query I know is costly missing?

Query 1 lists the top 100 shapes by on-demand bytes and the top 100 by slot time, in one project and one location, over the last 30 complete days. Run it in the project and location the query ran in.

Which prices does it use?

Google's USD list prices for the location you pick, across 48 BigQuery locations, read from its pricing page on 2026-11-07, before the free 1 TiB a month, discounts, credits and taxes.

About this list

A few query shapes usually carry most of a BigQuery bill. This page takes the costliest ones from your own job history and checks each two ways: its SQL, for patterns that read more than they need, and its runs, for repeats the cache did not serve, the 10 MB minimum and failures.

Each shape is ranked by what it costs now. A figure is shown only where the history supports one, and the rest are leads to look at, never a promised saving.

Related tools

More tools for: Analytics and warehouses

A fix list is a snapshot. New queries arrive every day.

Finitizer watches BigQuery continuously: the queries driving scan volume, slot sizing and storage billing, and the savings it verifies against later bills. Read-only.

See how Finitizer works

Rate this tool

How would you rate the BigQuery Query Fix List?