Skip to content
Software capabilities
Snowflake

Inspect recent Snowflake query history

Snowflake exposes recent query history in Snowsight and through the QUERY_HISTORY table function. Use the interface for interactive query profiles or Snowflake CLI to capture a repeatable SQL result.

Documentation reviewed · 2 methods with sources

Ways to do it

  1. CLI: snow sql with QUERY_HISTORY
  2. Interface: Snowsight Monitoring → Query History
CLI

snow sql with QUERY_HISTORY

Run an Information Schema QUERY_HISTORY table function through Snowflake CLI and return the most recent queries in a time window.

Read source: Snowflake QUERY_HISTORY table function
Requirements
Snowflake CLI configured with a connection, a role that can use the target database and schema, and MONITOR or OPERATE on warehouses when the result must include queries from other users.
Limitations
The Information Schema table function covers only the previous seven days and visibility depends on the active role. Snowflake also notes that some hybrid-table executions are not represented in this function.

Example shell

snow sql -q "SELECT query_id, user_name, execution_status, total_elapsed_time FROM TABLE(INFORMATION_SCHEMA.QUERY_HISTORY(END_TIME_RANGE_START => DATEADD('hour', -1, CURRENT_TIMESTAMP()), RESULT_LIMIT => 20)) ORDER BY start_time DESC"
Interface

Snowsight Monitoring → Query History

Open Snowsight, choose Monitoring, then Query History to filter individual or grouped queries and open query details and profiles.

Read source: Snowflake Snowsight Query History
Requirements
A Snowflake account login and a role with access to the query history being reviewed. MONITOR or OPERATE on a warehouse is needed to see queries from other users on that warehouse.
Limitations
The Snowsight Query History page covers queries from the last 14 days, while user information is omitted from details for queries older than seven days.