Snowflake snippets

How to find the most expensive query executed

If you want to query the longest queries executed you can use the following:

SELECT QUERY_TEXT, QUERY_TYPE, USER_NAME, ROLE_NAME
   database_name, warehouse_name, warehouse_size, execution_status,
   ROUND(total_elapsed_time/1000,3) elapsed_sec
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
ORDER BY total_elapsed_time DESC 
LIMIT 10;

Back to Snowflake cookbook page