EXPLAIN shows Snowflake’s execution plan, letting you diagnose and tune query performance.
EXPLAIN returns Snowflake’s compiled execution plan before a query runs. Reading the plan helps you understand joins, pruning, and parallelism, guiding index-like clustering and rewrite decisions.
Run EXPLAIN USING TEXT
, EXPLAIN USING JSON
, or simply EXPLAIN
before a SELECT, INSERT, UPDATE, or MERGE. Snowflake parses the statement and outputs the physical steps without executing it.
Use TEXT for quick, human-readable insight.Choose JSON when you need to feed the plan into scripts or dashboards, or want node-level statistics via GET_QUERY_OPERATOR_STATS
.
Look for SCAN nodes with large estimated rows, BROADCAST joins on big tables, and re-partition operations.These often signal the need for clustering keys or predicate pushdown.
Test individual sub-queries with EXPLAIN before examining the whole CTE chain.
Save pre- and post-optimization JSON plans in Galaxy’s Collections to track improvements and share with teammates.
After running the query, open Query Profile to validate the estimated vs.actual statistics you saw in EXPLAIN.
Add a clustering key on the high-cardinality column used in your filter. Then rerun EXPLAIN
to confirm the SCAN node shows fewer micro-partitions.
EXPLAIN on a view shows the view text, not the underlying tables. Wrap the view in a SELECT to see the real plan.
If tables were bulk-loaded recently, run ALTER TABLE ...REFRESH
for more accurate row-count estimates.
Galaxy’s AI copilot can auto-annotate JSON plans, highlight bottlenecks, and suggest clustering keys—all inside the editor.
.
No. Because the query never runs, only compilation resources are used, which are not billed.
No. EXPLAIN supports SELECT, INSERT, UPDATE, DELETE, MERGE, and COPY, but not CREATE or ALTER commands.
In the JSON plan, check the object_ref.partition_ranges
field under SCAN nodes.