EXPLAIN and EXPLAIN ANALYZE reveal BigQuery’s stage-by-stage execution plan, slot usage, and data movement so you can tune query cost and speed.
The plan lists each stage, its input bytes, shuffle bytes, estimated rows, and slot-time consumed. Reading it helps locate skewed joins, expensive scans, and unnecessary shuffles.
Prefix the statement with EXPLAIN
. BigQuery performs a dry-run and returns JSON plus a tabular view in the console, so no slots are billed.
Use EXPLAIN ANALYZE
.The query runs fully, then returns the same plan augmented with observed rows, bytes, and timing—ideal for verifying optimizations.
input_rows and input_bytes flag large scans. shuffle_output_bytes shows network-heavy stages. slot_ms reveals stages monopolizing compute.
Look for a join stage where one input is tiny and the other huge, or where parallel_inputs
differs greatly between sides.Consider reshuffling or clustering the large table.
Partition and cluster large tables, filter early, avoid SELECT *
, push aggregations below joins, and prefer EXISTS over DISTINCT when deduplicating.
Yes. The first column returned by EXPLAIN contains JSON. You can save it to Cloud Storage or feed it into visualization tools.
Dry-run EXPLAIN uses negligible resources and is free.EXPLAIN ANALYZE charges for the query because it executes fully.
Use ANALYZE when you need stage-level slot and shuffle metrics. Use INFORMATION_SCHEMA.JOBS_BY_*
for high-level job profiling across many queries.
.
No. EXPLAIN performs a dry-run; it never writes or mutates data.
Yes. Dry-run EXPLAIN incurs no slot or storage costs. Only EXPLAIN ANALYZE is billed as a normal query.
Currently, EXPLAIN supports only SELECT queries. Wrap DML in a SELECT preview to examine its plan indirectly.