Request a demo

BigQuery error · Quotas and rate limits

Too many DML statements outstanding against table

More than 20 UPDATE, DELETE, MERGE or TRUNCATE TABLE statements are already queued for one table, so BigQuery rejects the next one. It runs at most two mutating statements per table at a time. Batch many small statements into one MERGE: it fixes the error and, on-demand, cuts the bill.

Error reason resourcesExceeded · HTTP 400 · Checked against the Google Cloud docs in November 2026

The error message

Resources exceeded during query execution: Too many DML statements outstanding against table <project>:<dataset>.<table>, limit is 20.

Causes

Row-by-row updates from an application or pipeline

BigQuery runs up to 2 mutating DML statements (UPDATE, DELETE, MERGE) per table concurrently and queues up to 20 more as PENDING; TRUNCATE TABLE shares that queue. A service that issues one UPDATE per event, or a loop in a script, fills the queue in seconds.

Parallel tasks writing to the same table

Orchestrators often fan out one task per customer, partition or file, and each task runs its own MERGE into the same target table. All of them land in the same per-table queue.

Slow statements that drain the queue slowly

Each queued statement waits for one of the two running slots. A MERGE that rewrites a large unpartitioned table takes long to finish, so the queue backs up even at a modest submission rate.

Variants of the message

Some clients show it without the prefix, as Too many DML statements outstanding against <table>, limit is 20. INSERT statements have a separate queue of 100; overflowing the combined pending plus running DML for a table returns Quota exceeded: Your table exceeded quota for total number of DML jobs writing to a table, pending + running.

How to fix it

1. See what is filling the queue

List running and pending mutating statements and group them by user and table to find the job or service that submits them.

SELECT
  destination_table.table_id,
  user_email,
  state,
  COUNT(*) AS jobs,
  MIN(creation_time) AS oldest
FROM `region-us`.INFORMATION_SCHEMA.JOBS
WHERE creation_time > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY)
  AND statement_type IN ('UPDATE', 'DELETE', 'MERGE', 'TRUNCATE_TABLE')
  AND state IN ('RUNNING', 'PENDING')
GROUP BY 1, 2, 3
ORDER BY jobs DESC;

2. Stage changes, then apply them with one MERGE

Append changes to a staging table (load job, Storage Write API or INSERT), then apply them on a schedule with a single MERGE. One statement replaces hundreds. Deduplicate the staging rows first so the MERGE doesn't fail with UPDATE/MERGE must match at most one source row.

MERGE `project.crm.customers` AS t
USING (
  SELECT *
  FROM `project.crm.customer_changes`
  WHERE TRUE
  QUALIFY ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY changed_at DESC) = 1
) AS s
ON t.customer_id = s.customer_id
WHEN MATCHED THEN
  UPDATE SET email = s.email, plan = s.plan, updated_at = s.changed_at
WHEN NOT MATCHED THEN
  INSERT (customer_id, email, plan, updated_at)
  VALUES (s.customer_id, s.email, s.plan, s.changed_at);

3. Combine several UPDATEs into one

Updates that set different values for different keys can run as one statement with a CASE expression or a join to an inline list.

UPDATE `project.billing.invoices` AS i
SET status = u.status
FROM UNNEST([
  STRUCT(1001 AS invoice_id, 'paid' AS status),
  (1002, 'void'),
  (1003, 'paid')
]) AS u
WHERE i.invoice_id = u.invoice_id;

4. Limit concurrency in the orchestrator

Cap parallel tasks that write to the same table (an Airflow pool, a dbt thread limit, a queue with one consumer per table). Retrying immediately only refills the queue: retry with exponential backoff and jitter.

5. Partition or cluster the target table

Statements that touch fewer partitions finish faster, so the queue drains faster, and concurrent statements on different partitions don't conflict.

How to prevent it

  • Treat BigQuery as a batch engine: design writes as periodic MERGE jobs, not as per-event UPDATEs.
  • Alert on PENDING mutating DML per table in INFORMATION_SCHEMA.JOBS before it reaches 20.
  • On-demand, each UPDATE, DELETE or MERGE with an UPDATE or DELETE clause bills the statement's own bytes plus the size of the table (or of the touched partitions) it modifies. A hundred single-row updates on a 100 GiB unpartitioned table bill about 10 TiB, while one batched MERGE bills it once.

FAQ

Can I raise the limit of 20 queued DML statements?

No. The per-table queue of 20 mutating statements and the 2 concurrent statements are fixed system limits. Reduce the number of statements instead.

Am I billed for the rejected statements?

Rejected statements don't run, so on-demand they aren't billed. The statements that did run are billed in full, and with row-by-row writes that is where the cost is: each one rewrites its table or partitions.

Do INSERT statements count toward the limit of 20?

No. INSERT has its own queue: after 1,500 INSERT statements in 24 hours, concurrency per table drops to 10 and up to 100 more can wait. The limit of 20 applies to UPDATE, DELETE, MERGE and TRUNCATE TABLE.

How long can a DML statement wait in the queue?

An interactive DML statement can wait up to 7 hours. After that it fails with DML statement has been queued for too long.

SQL reference

More quotas and rate limits

All BigQuery error messages · What 50M daily events say about BigQuery failures

Stop finding BigQuery failures in Slack threads

Masthead watches every BigQuery job, dbt model, Dataform action and Airflow task from audit logs, groups failures into incidents and shows which tables and dashboards are affected. No access to your data and no added BigQuery cost.