How to find slow Snowflake queries

Most Snowflake slowness comes from three causes: spilling to local or remote storage, poor partition pruning, and warehouse queueing. You can see all three in SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY.

1. Top queries by elapsed time (last 7 days)

SELECT query_id, warehouse_name, user_name,
       total_elapsed_time/1000 AS seconds,
       bytes_spilled_to_local_storage, bytes_spilled_to_remote_storage,
       partitions_scanned, partitions_total
FROM snowflake.account_usage.query_history
WHERE start_time > DATEADD(day,-7,CURRENT_TIMESTAMP())
  AND execution_status='SUCCESS'
ORDER BY total_elapsed_time DESC LIMIT 25;

2. Read the signals

3. Repeat offenders

Group by query_parameterized_hash to find one query pattern that runs thousands of times. Fixing it once pays off on every run.

Ready-made SQL from Thyne Ventures

Snowflake Query Performance Tuning Kit ($29): 10 SQL scripts to find spilling, pruning failures, queueing and slow queries.

Snowflake Cost + Security Audit Bundle ($79): All 21 cost and security scripts together.

Published by Thyne Ventures. Snowflake is a trademark of Snowflake Inc.; we are not affiliated.