EXPLAIN shows Snowflake’s step-by-step execution plan so you can diagnose slow queries and optimize them.
EXPLAIN reveals how Snowflake will execute a SQL statement before it runs. Reviewing the logical or physical plan highlights expensive scans, joins, and data shuffling that cause high warehouse cost and latency.
Prepend EXPLAIN to the statement or enclose it with EXPLAIN USING TYPE = 'logical|physical|json'. Run the command in the Snowflake worksheet or any client. The plan appears instantly, and the query does not execute.
EXPLAIN USING TYPE = 'logical'
SELECT *
FROM Orders o JOIN Customers c ON c.id = o.customer_id;
• SCANNED OBJECT shows which micro-partitions are touched.
• FILTER indicates push-down predicates.
• JOIN reveals join type (MERGE, HASH, NESTED LOOP).
• AGGREGATE lists grouping keys and functions.
After you actually run the statement, Snowsight’s Query Profile visualizes step duration, data volume, and spilled bytes. Use it to confirm assumptions made from EXPLAIN and spot unexpected skew.
Start with the heaviest node (largest PARTITIONS or ROWS). Add selective predicates earlier, cluster frequently filtered columns, and convert cross joins to explicit joins. Verify pruning by checking PARTITIONS_SCANNED.
Yes. Use EXPLAIN USING TYPE = 'json' and insert the JSON into a VARIANT column for later comparison during regression testing.
No. EXPLAIN never executes the query, so the warehouse stays suspended and no credits are billed.
Yes, open History » Query Profile or query ACCOUNT_USAGE.QUERY_HISTORY and click the profile link.
Snowflake replicates the smaller table to every node to avoid shuffling both sides. If the small table grows, switch to PARTITIONED JOIN with a hint.