Script Find long running Queries in Snowflake
- Kunal Ranpura
- Mar 8, 2023
- 1 min read
select Total_Elapsed_Time/60000 Total_Time_MINS, Database_name, schema_name, User_name, Role_name, Warehouse_name, Warehouse_size, Query_TEXT
from snowflake.account_usage.query_history
where START_TIME between dateadd(day, -7, current_date()) and current_date()
and error_code is null and DATABASE_NAME IN ('DB_NAME')
and Query_text is not null and WAREHOUSE_SIZE IS NOT NULL
order by TOTAL_ELAPSED_TIME desc
limit 10;
Comments