Study FAQ
Which Snowflake Query History source should I use?
Also asked as 2
- How do Snowsight, Information Schema, and ACCOUNT_USAGE Query History differ?
- Where can I look up a recent Snowflake query versus report on longer query history?
Answer
Use Snowsight Query History for a recent query you want to inspect interactively, Information Schema QUERY_HISTORY functions for recent SQL-based investigation, or SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY for account-level trends. Snowsight covers up to 14 days. The table functions cover the last 7 days. The Account Usage view covers 365 days and can lag by up to 45 minutes.
In Snowsight, filter by query ID, status, user, warehouse, statement type, duration, session, or query tag as needed. The active role affects whose queries you can see. Details for queries over seven days old can omit user information, while the user filter remains available. Snowsight uses your current time zone. Normalize timestamps before joining events from several sources.
The Information Schema functions include session, user, and warehouse variants. Supply a small recent time window and a sufficient result limit, since the function applies its time range and result limit before the outer WHERE predicate. For longer reporting, use a role authorized for the Account Usage view. This query lists slow statements visible in the previous 24 hours.
SELECT query_id, user_name, warehouse_name, total_elapsed_time,
bytes_scanned, error_code
FROM snowflake.account_usage.query_history
WHERE start_time >= DATEADD(hour, -24, CURRENT_TIMESTAMP())
ORDER BY total_elapsed_time DESC
LIMIT 50;
The result ranks elapsed time. Use the query ID and its timing breakdown or profile to find the cause. If a recent query is absent, check the selected account, role, time range, and the view’s update delay.
Snowsight Query History · Information Schema QUERY_HISTORY functions · Account Usage QUERY_HISTORY view
Full explanation
Monitoring Queries, Warehouses, Storage, and Account Activity
Study guide · COF-C03
Read the full explanation