Database / Snowflake Interview Questions
What is the Snowflake Query Profile and how do you use it to diagnose slow queries?
Query Profile is Snowflake's built-in visual execution plan viewer, available in Snowsight under Query History for any completed or actively running query. It shows the full operator tree for a query execution — every node representing a distinct processing step — along with timing, row counts, and resource metrics at each step. It is your first stop when a query is slower than expected.
Key operator node types: TableScan (reads micro-partitions), Filter, Aggregate, Join, Sort, Exchange (shuffle data between nodes), Projection.
The most important diagnostic signals:
- Partitions Scanned vs Partitions Total — if scanned is close to total, the query is not pruning well. Consider adding a clustering key on the filter columns.
- Bytes Spilled to Local Storage — the warehouse ran out of in-memory space for intermediate results; consider scaling up the warehouse size.
- Bytes Spilled to Remote Storage — even worse spilling to cloud storage; a significantly larger warehouse or a query rewrite is needed.
- Bytes Sent over Network in Join nodes — large data shuffle between nodes; pushing down more filters earlier can reduce this.
- Compilation Time vs Execution Time — very high compilation time relative to execution indicates a complex query plan; simplify CTEs or break into steps.
- % of execution per node — a single node consuming 90%+ of time is the bottleneck; focus optimization there.
More Related questions...