Find queries executed in specific time range in Snowflake

Article for: Amazon Redshift Teradata Vertica

Snowflake enables you to check last query executed in specific time range

Notes

Function used in this query return query activity within the last 7 days and maximum 100 of them.

Query

Query below lists queries executed between six and three days from current time.

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(
            dateadd(day, -6, current_timestamp()),
            dateadd(day, -3, current_timestamp()) ))
order by start_time desc;

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 specifiic time range
  • Scope of rows: all queries executed in specifiic time range
  • Ordered by start time of query

Sample results

sample results

Using Web User Interface

In Web User Interface you can list only queries finished before specific time. To do this click on Query tab (1) and next add filter by clicking on Add a filter (2).

Next, select End Time type of filter (3) and provide date in text boxes (4).

Result: