Schemas:

ACCOUNT_USAGE , READER_ACCOUNT_USAGE

QUERY_HISTORY View

This Account Usage view can be used to query Snowflake query history by various dimensions (time range, session, user, warehouse, etc.) within the last 365 days (1 year).

The view is available in both the ACCOUNT_USAGE and READER_ACCOUNT_USAGE schemas with the following differences:

  • The following column is available only in the reader account view:

    • READER_ACCOUNT_NAME

  • The following columns are not provided in the reader account view:

    • CLUSTER_NUMBER

    • BYTES_SCANNED

    • ROWS_PRODUCED

    • OUTBOUND_DATA_TRANSFER_CLOUD

    • INBOUND_DATA_TRANSFER_CLOUD

    • INBOUND_DATA_TRANSFER_REGION

    • INBOUND_DATA_TRANSFER_BYTES

See also:

QUERY_HISTORY , QUERY_HISTORY_BY_* (Information Schema table function)

Columns

Column Name

Data Type

Description

READER_ACCOUNT_NAME

TEXT

Name of the reader account in which the the SQL statement was executed.

QUERY_ID

TEXT

Internal/system-generated identifier for the SQL statement.

QUERY_TEXT

TEXT

Text of the SQL statement.

DATABASE_ID

NUMBER

Internal/system-generated identifier for the database that was in use.

DATABASE_NAME

TEXT

Database that was in use at the time of the query.

SCHEMA_ID

NUMBER

Internal/system-generated identifier for the schema that was in use.

SCHEMA_NAME

TEXT

Schema that was in use at the time of the query.

QUERY_TYPE

TEXT

DML, query, etc. If the query is currently running, or the query failed, then the query type may be UNKNOWN.

SESSION_ID

NUMBER

Session that executed the statement.

USER_NAME

TEXT

User who issued the query.

ROLE_NAME

TEXT

Role that was active in the session at the time of the query.

WAREHOUSE_ID

NUMBER

Internal/system-generated identifier for the warehouse that was used.

WAREHOUSE_NAME

TEXT

Warehouse that the query executed on, if any.

WAREHOUSE_SIZE

TEXT

Size of the warehouse when this statement executed.

WAREHOUSE_TYPE

TEXT

Type of the warehouse when this statement executed.

CLUSTER_NUMBER

NUMBER

The cluster (in a multi-cluster warehouse) that this statement executed on.

QUERY_TAG

TEXT

Query tag set for this statement through the QUERY_TAG session parameter.

EXECUTION_STATUS

TEXT

Execution status for the query: resuming_warehouse, running, queued, blocked, success, failed_with_error, or failed_with_incident.

ERROR_CODE

NUMBER

Error code, if the query returned an error

ERROR_MESSAGE

TEXT

Error message, if the query returned an error

START_TIME

TIMESTAMP_LTZ

Statement start time (in the UTC time zone)

END_TIME

TIMESTAMP_LTZ

Statement end time (in the UTC time zone), or NULL if the statement is still running.

TOTAL_ELAPSED_TIME

NUMBER

Elapsed time (in milliseconds)

BYTES_SCANNED

NUMBER

Number of bytes scanned by this statement.

ROWS_PRODUCED

NUMBER

Number of rows produced by this statement.

COMPILATION_TIME

NUMBER

Compilation time (in milliseconds)

EXECUTION_TIME

NUMBER

Execution time (in milliseconds)

QUEUED_PROVISIONING_TIME

NUMBER

Time (in milliseconds) spent in the warehouse queue, waiting for the warehouse servers to provision, due to warehouse creation, resume, or resize.

QUEUED_REPAIR_TIME

NUMBER

Time (in milliseconds) spent in the warehouse queue, waiting for servers in the warehouse to be repaired.

QUEUED_OVERLOAD_TIME

NUMBER

Time (in milliseconds) spent in the warehouse queue, due to the warehouse being overloaded by the current query workload.

TRANSACTION_BLOCKED_TIME

NUMBER

Time (in milliseconds) spent blocked by a concurrent DML.

OUTBOUND_DATA_TRANSFER_CLOUD

TEXT

Target cloud provider for statements that unload data to another region and/or cloud.

OUTBOUND_DATA_TRANSFER_REGION

TEXT

Target region for statements that unload data to another region and/or cloud.

OUTBOUND_DATA_TRANSFER_BYTES

NUMBER

Number of bytes transferred in statements that unload data to another region and/or cloud.

INBOUND_DATA_TRANSFER_CLOUD

TEXT

Source cloud provider for statements that load data from another region and/or cloud.

INBOUND_DATA_TRANSFER_REGION

TEXT

Source region for statements that load data from another region and/or cloud.

INBOUND_DATA_TRANSFER_BYTES

NUMBER

Number of bytes transferred in statements that load data from another region and/or cloud.

LIST_EXTERNAL_FILES_TIME

NUMBER

Time (in milliseconds) spent listing external files.

CREDITS_USED_CLOUD_SERVICES

NUMBER

Number of credits used for cloud services in the hour.

Usage Notes

  • Latency for the view may be up to 45 minutes.