Find queries executed in specific warehouse in Snowflake

Snowflake enables you to check last query executed in specific warehouse.

Notes

Function used in this query return query activity within the last 7 days and maximum 100 of them. To watch queries executed in other warehouses you need to have MONITOR privilege on these warehouses.

Query

select query_text,
       warehouse_name,
       database_name,
       schema_name,
       user_name,
       role_name,
       execution_status,
       error_code,
       error_message,
       start_time,
       end_time
from table(information_schema.QUERY_HISTORY_BY_WAREHOUSE('DATAHOUSE'))
order by start_time desc;                           -- put warehouse name here

Columns

  • query_text - most recent query text
  • warehouse_name - name of warehouse in which query was executed
  • database_name - name of database in which query was executed
  • schema_name - name of schema in which query was executed
  • user_name - name of user who executed query
  • role_name - role name of user who executed query
  • execution_status - current status of executed query
  • error_code - error code, if the query returned an error
  • error_message - error message, if the query returned an error
  • start_time - start time of query
  • end_time - end time of query

Rows

  • One row represents one query executed in specific warehouse
  • Scope of rows: all queries executed in specific warehouse
  • Ordered by start time of query

Sample results

sample results

Using Web User Interface

In Web User Interface you can watch last executed queries by clicking on Query tab (1) . To obtain last query excuted in specific warehouse, we need to add filter by clicking on Add a filter (2).

Next, select Warehouse type of filter (3) and select warehouse (4).

Result:

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.