Back to Utils
Snowflake · View
spilling_queries
Queries that spilled data to remote disk. Remote spill indicates the warehouse is undersized for the query, or the query is scanning more data than necessary.
Source: SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY · Latency: ~45min
| Column | Description |
|---|---|
| date | Date |
| user_name | User |
| role_name | Role |
| warehouse_name | Warehouse |
| query_type | e.g. SELECT, INSERT |
| execution_seconds | Total elapsed time in seconds |
| gb_spilled_local | Data spilled to local disk in GB |
| gb_spilled_remote | Data spilled to remote disk in GB |
| gb_scanned | Data scanned in GB |
| statement | Full query text |
Source code
create_admin_views.sql
create or replace view spilling_queries
comment = 'Queries that spilled to remote disk (source: SNOWFLAKE.ACCOUNT_USAGE)'
as
select start_time::date as date
, user_name
, role_name
, warehouse_name
, query_type
, round(total_elapsed_time / 1000.0, 1) as execution_seconds
, round(bytes_spilled_to_local_storage / 1024.0 / 1024 / 1024, 2) as gb_spilled_local
, round(bytes_spilled_to_remote_storage / 1024.0 / 1024 / 1024, 2) as gb_spilled_remote
, round(bytes_scanned / 1024.0 / 1024 / 1024, 2) as gb_scanned
, query_text as statement
from snowflake.account_usage.query_history
where bytes_spilled_to_remote_storage > 0
order by bytes_spilled_to_remote_storage desc;