Account Usage

In the SNOWFLAKE database, the ACCOUNT_USAGE and READER_ACCOUNT_USAGE schemas enable querying object metadata, as well as historical usage data, for your account and all reader accounts (if any) associated with the account.

Overview of Account Usage schemas

ACCOUNT_USAGE:

Views that display object metadata and usage metrics for your account.

In general, these views mirror the corresponding views and table functions in the Snowflake Snowflake Information Schema, but with the following differences:

  • Records for dropped objects included in each view.
  • Longer retention time for historical usage data.
  • Data latency.

For more details, see Differences Between Account Usage and Information Schema (in this topic). For more details about each view, see ACCOUNT_USAGE Views (in this topic).

READER_ACCOUNT_USAGE:

Views that display object metadata and usage metrics for all the reader accounts that have been created for your account (as a Secure Data Sharing provider).

These views are a small subset of the ACCOUNT_USAGE views that apply to reader accounts. Also, each view in this schema contains an additional READER_ACCOUNT_NAME column for filtering results by reader account.

For more details about each view, see READER_ACCOUNT_USAGE Views (in this topic).

Note that these views are empty if no reader accounts have been created for your account.

Differences between Account Usage and Information Schema

The Account Usage views and the corresponding views (or table functions) in the Snowflake Information Schema utilize identical structures and naming conventions, but with some key differences, as described in this section:

DifferenceAccount UsageInformation Schema
Includes dropped objectsYesNo
Latency of dataFrom 45 minutes to 3 hours (varies by view)None
Retention of historical data1 YearFrom 7 days to 6 months (varies by view/table function)

For more details, see the following sections.

Dropped object records

Account usage views include records for all objects that have been dropped. Many of the views for object types contain an additional DELETED column that displays the timestamp when the object was dropped.

In addition, because objects can be dropped and recreated with the same name, to differentiate between objects records that have the same name, the account usage views include ID columns, where appropriate, that display the internal IDs generated and assigned to each record by the system.

If a column for an object name (e.g. the TABLE_NAME column) is NULL, that object has been dropped. In this case, the columns for the names and IDs of the parent objects (e.g. the DATABASE_NAME and SCHEMA_NAME columns) are also NULL.

Note that in some views, the column for the object name might still contain the name of the object, even if the object has been dropped.

Data latency

Due to the process of extracting the data from Snowflake’s internal metadata store, the account usage views have some natural latency:

  • For most of the views, the latency is 2 hours (120 minutes).
  • For the remaining views, the latency varies between 45 minutes and 3 hours.

For details, see the list of views for each schema (in this topic). Also, note that these are all maximum time lengths; the actual latency for a given view when the view is queried may be less.

In contrast, views/table functions in the Snowflake Information Schema do not have any latency.

Historical data retention

Certain account usage views provide historical usage metrics. The retention period for these views is 1 year (365 days).

In contrast, the corresponding views and table functions in the Snowflake Information Schema have much shorter retention periods, ranging from 7 days to 6 months, depending on the view.

ACCOUNT_USAGE views

The ACCOUNT_USAGE schema contains the following views:

ViewTypeLatency [1]Edition [3]Notes
ACCESS_HISTORYHistorical3 hoursEnterprise Edition (or higher)Data retained for 1 year.
AGGREGATE_ACCESS_HISTORYHistorical3 hoursEnterprise Edition (or higher)Data retained for 1 year.
AGGREGATE_QUERY_HISTORYHistorical3 hours
AGGREGATION_POLICIESObject2 hours
ALERT_HISTORYHistorical3 hoursData retained for 1 year.
ANOMALIES_DAILYHistorical3 hoursData retained for 1 year.
APPLICATION_CALLBACK_HISTORYHistorical3 hoursData retained for 1 year.
APPLICATION_CONFIGURATIONSObject3 hoursData retained for 1 year.
APPLICATION_CONFIGURATION_VALUE_HISTORYHistorical3 hoursData retained for 1 year.
APPLICATION_DAILY_USAGE_HISTORYHistorical24 hoursData retained for 1 year.
APPLICATION_SPECIFICATION_STATUS_HISTORYHistorical1 hourData retained for 1 year.
APPLICATION_SPECIFICATIONSHistorical1 hourData for deleted app specifications is retained for 1 year.
ARCHIVE_STORAGE_DATA_RETRIEVAL_USAGE_HISTORYHistorical1 hourData retained for 1 year.
AUTOMATIC_CLUSTERING_HISTORYHistorical3 hoursData retained for 1 year.
BACKUP_OPERATION_HISTORYHistorical6 hoursData retained for 1 year.
BACKUP_POLICIESObject6 hours
BACKUP_SETSObject6 hours
BACKUP_STORAGE_USAGEHistorical6 hoursData retained for 1 year.
BACKUPSObject6 hours
BLOCK_STORAGE_HISTORYHistorical3 hoursData retained for 1 year.
BLOCK_STORAGE_SNAPSHOTSObject3 hours
CATALOG_LINKED_DATABASE_USAGE_HISTORYHistorical3 hoursData retained for 1 year.
CLASS_INSTANCESObject3 hoursData retained for 1 year.
CLASSESObject3 hoursData retained for 1 year.
COLUMN_QUERY_PRUNING_HISTORYHistorical4 hoursData retained for 1 year.
COLUMNSObject90 minutes
COMPLETE_TASK_GRAPHSHistorical45 minutesData retained for 1 year.
COMPUTE_POOLSHistorical3 hoursData retained for 1 year.
CONTACT_REFERENCESObject3 hours
CONTACTSObject3 hours
COPY_FILES_HISTORYHistoricalData retained for 1 year.
COPY_HISTORYHistorical2 hours [2]Data retained for 1 year.
CORTEX_AGENT_USAGE_HISTORYHistoricalData retained for 1 year.
CORTEX_AI_FUNCTIONS_USAGE_HISTORYHistoricalData retained for 1 year.
CORTEX_AISQL_USAGE_HISTORYHistoricalData retained for 1 year.
CORTEX_CODE_CLI_USAGE_HISTORYHistorical1 hourData retained for 1 year.
CORTEX_CODE_SNOWSIGHT_USAGE_HISTORYHistorical1 hourData retained for 1 year.
CORTEX_ANALYST_USAGE_HISTORYHistoricalOne hourData retained for 1 year.
CORTEX_DOCUMENT_PROCESSING_USAGE_HISTORYHistorical1 hourData retained for 1 year.
CORTEX_FINE_TUNING_USAGE_HISTORYHistorical1 hourData retained for 1 year.
CORTEX_FUNCTIONS_QUERY_USAGE_HISTORYHistoricalData retained for 1 year.
CORTEX_FUNCTIONS_USAGE_HISTORYHistoricalData retained for 1 year.
CORTEX_PROVISIONED_THROUGHPUT_USAGE_HISTORYHistoricalData retained for 1 year.
CORTEX_REST_API_RATE_LIMIT_POLICIESObject6 hours
CORTEX_REST_API_USAGE_HISTORYHistoricalData retained for 1 year.
CORTEX_SEARCH_BATCH_QUERY_USAGE_HISTORYHistorical1 hourData retained for 1 year.
CORTEX_SEARCH_DAILY_USAGE_HISTORYHistorical3 hoursData retained for 1 year.
CORTEX_SEARCH_SERVING_USAGE_HISTORYHistorical1 hourData retained for 1 year.
CREDENTIALSObject2 hours
DATA_CLASSIFICATION_HISTORYHistorical3 hoursEnterprise Edition (or higher)Data is retained for one year.
DATA_CLASSIFICATION_LATESTObject3 hoursEnterprise Edition (or higher)Data retained for as long as the table exists.
DATA_METRIC_FUNCTION_EXPECTATIONSObject30 minutesEnterprise Edition (or higher)
DATA_METRIC_FUNCTION_REFERENCESObject3 hoursEnterprise Edition (or higher)
DATA_QUALITY_MONITORING_USAGE_HISTORYHistorical3 hoursEnterprise Edition (or higher)Data retained for 1 year.
DATABASESObject3 hours
DATABASE_REPLICATION_USAGE_HISTORYHistorical3 hoursData retained for 1 year.
DATABASE_STORAGE_USAGE_HISTORYHistorical3 hoursData retained for 1 year.
DATA_TRANSFER_HISTORYHistorical2 hoursData retained for 1 year.
DOCUMENT_AI_USAGE_HISTORYHistoricalData retained for 1 year.
DYNAMIC_TABLE_REFRESH_HISTORYHistorical3 hoursData retained for 1 year.
ELEMENT_TYPESObject90 minutes
EVENT_USAGE_HISTORYHistorical3 hoursData retained for 1 year.
EXTERNAL_ACCESS_HISTORYHistorical2 hoursData retained for 1 year.
FIELDSObject90 minutes
FILE_FORMATSObject2 hours
FUNCTIONSObject2 hours
GRANTS_TO_ROLESObject2 hours
GRANTS_TO_SHARESObject3 hours
GRANTS_TO_USERSObject2 hours
HYBRID_TABLESObject3 hours
HYBRID_TABLE_USAGE_HISTORYHistorical3 hoursData retained for 1 year. (As of March 1, 2026, hybrid table requests are no longer billed, and metering was disabled soon after this pricing change took effect.)
ICEBERG_STORAGE_OPTIMIZATION_HISTORYHistorical2 hoursData retained for 1 year.
INDEX_COLUMNSObject3 hours
INDEXESObject3 hours
INGRESS_NETWORK_ACCESS_HISTORYHistorical4 hoursData retained for 1 year.
INTERNAL_DATA_TRANSFER_HISTORYHistorical3 hours
INTERNAL_STAGE_NETWORK_ACCESS_HISTORYHistorical6 hoursData retained for 1 year.
JOIN_POLICIESObject2 hours
LISTINGSObject3 hours
LOAD_HISTORYHistorical90 minutes [2]Data retained for 1 year.
LOCK_WAIT_HISTORYHistorical3 hoursData retained for 1 year.
LOGIN_HISTORYHistorical2 hoursData retained for 1 year.
MASKING_POLICIESObject2 hours
MATERIALIZED_VIEW_REFRESH_HISTORYHistorical3 hoursEnterprise Edition (or higher)Data retained for 1 year.
METERING_DAILY_HISTORYHistorical3 hoursData retained for 1 year.
METERING_HISTORYHistorical3 hoursData retained for 1 year.
NETWORK_POLICIESObject2 hours
NETWORK_RULE_REFERENCESObject2 hours
NETWORK_RULESObject2 hours
NOTEBOOKS_CONTAINER_RUNTIME_HISTORYHistorical3 hours
OBJECT_ACCESS_REQUEST_HISTORYHistorical3 hours
OBJECT_DEPENDENCIESHistorical3 hours
ONLINE_FEATURE_TABLE_REFRESH_HISTORYHistorical3 hours
OPENFLOW_USAGE_HISTORYHistorical3 hours
OUTBOUND_PRIVATELINK_ENDPOINTSObject2 hoursBusiness Critical (or higher)Data for deleted endpoints is retained for 1 year.
PASSWORD_POLICIESObject2 hours
PIPESObject2 hours
PIPE_USAGE_HISTORYHistorical3 hoursData retained for 1 year.
POLICY_REFERENCESObject2 hours
POSTGRES_STORAGE_USAGE_HISTORYHistorical3 hoursData retained for 1 year.
PRIVACY_BUDGETSObject24 hoursEnterprise Edition (or higher)
PRIVACY_POLICIESObject2 hoursEnterprise Edition (or higher)
PROCEDURESObject2 hours
PROJECTION_POLICIESObject2 hours
QUERY_ACCELERATION_ELIGIBLEHistorical3 hoursData retained for 1 year.
QUERY_ACCELERATION_HISTORYHistorical3 hoursEnterprise Edition (or higher)Data retained for 1 year.
QUERY_ATTRIBUTION_HISTORYHistorical8 hoursData retained for 1 year.
QUERY_HISTORYHistorical45 minutesData retained for 1 year.
QUERY_INSIGHTSHistoricalData retained for 1 year.
REFERENTIAL_CONSTRAINTSObject2 hours
REPLICATION_GROUP_REFRESH_HISTORYHistorical3 hoursData retained for 1 year.
REPLICATION_GROUP_USAGE_HISTORYHistorical3 hoursData retained for 1 year.
REPLICATION_GROUPSObject2 hours
REPLICATION_USAGE_HISTORYHistorical3 hoursData retained for 1 year.
RESOURCE_MONITORSObject2 hours
ROLESObject2 hours
ROW_ACCESS_POLICIESObject2 hours
SCHEMATAObject2 hours
SEARCH_OPTIMIZATION_BENEFITSHistorical6 hoursEnterprise Edition (or higher)Data retained for 1 year.
SEARCH_OPTIMIZATION_HISTORYHistorical3 hoursEnterprise Edition (or higher)Data retained for 1 year.
SECRETSObject2 hours
SEMANTIC_DIMENSIONSObject2 hours
SEMANTIC_FACTSObject2 hours
SEMANTIC_METRICSObject2 hours
SEMANTIC_RELATIONSHIPSObject2 hours
SEMANTIC_TABLESObject2 hours
SEMANTIC_VIEWSObject2 hours
SEQUENCESObject2 hours
SERVERLESS_ALERT_HISTORYHistorical3 hoursData retained for 1 year.
SERVERLESS_TASK_HISTORYHistorical3 hoursData retained for 1 year.
SERVICESObject3 hours
SESSION_POLICIESObject2 hours
SESSIONSHistorical3 hoursData retained for 1 year.
SHARESObject3 hours
SNAPSHOT_OPERATION_HISTORYHistorical6 hoursData retained for 1 year. This view is deprecated. Use the BACKUP_OPERATION_HISTORY view instead.
SNAPSHOT_POLICIESObject6 hoursThis view is deprecated. Use the BACKUP_POLICIES view instead.
SNAPSHOT_SETSObject6 hoursThis view is deprecated. Use the BACKUP_SETS view instead.
SNAPSHOT_STORAGE_USAGEHistorical6 hoursData retained for 1 year. This view is deprecated. Use the BACKUP_STORAGE_USAGE view instead.
SNAPSHOTSObject6 hoursThis view is deprecated. Use the BACKUPS view instead.
SNOWFLAKE_INTELLIGENCE_USAGE_HISTORYHistoricalData retained for 1 year.
SNOWPARK_CONTAINER_SERVICES_HISTORYHistorical3 hourData retained for 1 year.
SNOWPIPE_STREAMING_CHANNEL_HISTORYHistorical
SNOWPIPE_STREAMING_CLIENT_HISTORYHistorical2 hoursData retained for 1 year.
SNOWPIPE_STREAMING_FILE_MIGRATION_HISTORYHistorical12 hoursData retained for 1 year.
STAGESObject2 hours
STAGE_STORAGE_USAGE_HISTORYHistorical2 hoursData retained for 1 year.
STORAGE_LIFECYCLE_POLICIESObject2 hours
STORAGE_LIFECYCLE_POLICY_HISTORYHistorical2 hoursData retained for 1 year.
STORAGE_REQUEST_HISTORYHistorical6 hoursData retained for 1 year.
STORAGE_USAGEHistorical2 hoursCombined usage across all database tables and internal stages. Data retained for 1 year.
TABLESObject90 minutes
TABLE_CONSTRAINTSObject2 hours
TABLE_DML_HISTORYHistorical6 hoursData retained for 1 year.
TABLE_PRUNING_HISTORYHistorical6 hoursData retained for 1 year.
TABLE_QUERY_PRUNING_HISTORYHistorical4 hoursData retained for 1 year.
TABLE_STORAGE_METRICSObject90 minutes
TAG_REFERENCESObject2 hours
TAGSObject2 hours
TASK_HISTORYHistorical45 minutes
TASK_VERSIONSObject3 hours
TRI_SECRET_SECURE_HISTORYHistorical2 hours
TRUST_CENTER_FINDINGSHistorical1 hour
TYPESObject2 hours
USERSObject2 hours
VIEWSObject90 minutes
WAREHOUSE_EVENTS_HISTORYHistorical3 hoursData retained for 1 year.
WAREHOUSE_LOAD_HISTORYHistorical3 hoursData retained for 1 year.
WAREHOUSE_METERING_HISTORYHistorical3 hoursData retained for 1 year.

[1] All latency times are approximate; in some instances, the actual latency may be lower.

[2] The latency of the views for a given table may be up to 2 days if both of the following conditions are true: 1. Fewer than 32 DML statements have been added to the given table since it was last updated in LOAD_HISTORY or COPY_HISTORY. 2. Fewer than 100 rows have been added to the given table since it was last updated in LOAD_HISTORY or COPY_HISTORY.

[3] Unless otherwise noted, the Account Usage view is available to all accounts.

Account Usage table functions

Currently, Snowflake supports one ACCOUNT_USAGE table function:

Table FunctionData RetentionNotes
TAG_REFERENCES_WITH_LINEAGEN/AResults are only returned for the role that has access to the specified object.

Note

Similar to the Account Usage views, please account for latency when calling this table function. The expected latency for this table function is similar to the latency for the TAG_REFERENCES view.

READER_ACCOUNT_USAGE views

The READER_ACCOUNT_USAGE schema contains the following views:

ViewTypeLatency [1]Notes
LOGIN_HISTORYHistorical2 hoursData retained for 1 year.
QUERY_HISTORYHistorical45 minutesData retained for 1 year.
RESOURCE_MONITORSObject2 hours
STORAGE_USAGEHistorical24 hoursCombined usage across all database tables and internal stages. Data retained for 1 year.
WAREHOUSE_METERING_HISTORYHistorical24 hoursData retained for 1 year.

[1] All latency times are approximate; in some instances, the actual latency may be lower.

Enabling other roles to use schemas in the SNOWFLAKE database

By default, the SNOWFLAKE database is visible to all users; however, access to schemas in this database can be granted by a user with the ACCOUNTADMIN role using either of the following approaches:

Important

To avoid unintentionally granting access to organization-level data, consider using SNOWFLAKE database roles to grant access to views in the ACCOUNT_USAGE schema.

For more information, refer to GRANT DATABASE ROLE.

For example, to grant IMPORTED PRIVILEGES on the SNOWFLAKE database to two additional roles:

USE ROLE ACCOUNTADMIN;

GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE SYSADMIN;
GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE customrole1;

A user with that is granted the customrole1 role can query a view as follows:

USE ROLE customrole1;

SELECT database_name, database_owner FROM SNOWFLAKE.ACCOUNT_USAGE.DATABASES;

For additional examples, see Querying the Account Usage views.

ACCOUNT_USAGE schema SNOWFLAKE database roles

In addition, you can grant finer control to accounts using SNOWFLAKE Database roles. For more information on database roles, see database roles.

ACCOUNT_USAGE schemas have four defined SNOWFLAKE database roles, each granted the SELECT privilege on specific views.

RolePurpose and Description
OBJECT_VIEWERThe OBJECT_VIEWER role provides visibility into object metadata.
USAGE_VIEWER

The USAGE_VIEWER role provides visibility into historical usage information.

GOVERNANCE_VIEWER

The GOVERNANCE_VIEWER role provides visibility into data governance related information.

SECURITY_VIEWER

The SECURITY_VIEWER role provides visibility into security based information.

Database role required to access ACCOUNT_USAGE views

The OBJECT_VIEWER, USAGE_VIEWER, GOVERNANCE_VIEWER, and SECURITY_VIEWER roles have the SELECT privilege to query Account Usage views in the shared SNOWFLAKE database. Use the following table to determine which database role has access to a view.

ViewDatabase Role

ACCESS_HISTORY view

GOVERNANCE_VIEWER

APPLICATION_CONFIGURATIONS view

SECURITY_VIEWER

AGGREGATE_ACCESS_HISTORY view

GOVERNANCE_VIEWER

AGGREGATE_QUERY_HISTORY view

GOVERNANCE_VIEWER

AGGREGATION_POLICIES view

GOVERNANCE_VIEWER

ANOMALIES_DAILY view

USAGE_VIEWER

APPLICATION_CALLBACK_HISTORY view

SECURITY_VIEWER

APPLICATION_CONFIGURATION_VALUE_HISTORY view

SECURITY_VIEWER

APPLICATION_DAILY_USAGE_HISTORY view

USAGE_VIEWER

APPLICATION_SPECIFICATION_STATUS_HISTORY view

SECURITY_VIEWER

APPLICATION_SPECIFICATIONS view

SECURITY_VIEWER

ARCHIVE_STORAGE_DATA_RETRIEVAL_USAGE_HISTORY view

USAGE_VIEWER

AUTOMATIC_CLUSTERING_HISTORY view

USAGE_VIEWER

BLOCK_STORAGE_HISTORY view

USAGE_VIEWER

BLOCK_STORAGE_SNAPSHOTS view

OBJECT_VIEWER

CATALOG_LINKED_DATABASE_USAGE_HISTORY view

USAGE_VIEWER

CLASS_INSTANCES view

USAGE_VIEWER
CLASSES viewUSAGE_VIEWER

COLUMN_QUERY_PRUNING_HISTORY view

USAGE_VIEWER
COLUMNS viewOBJECT_VIEWER

COMPLETE_TASK_GRAPHS view

OBJECT_VIEWER

CONTACT_REFERENCES view

GOVERNANCE_VIEWER
CONTACTS viewGOVERNANCE_VIEWER

COPY_FILES_HISTORY view

USAGE_VIEWER
COPY_HISTORY viewUSAGE_VIEWER

CORTEX_AI_FUNCTIONS_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_AGENT_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_AISQL_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_ANALYST_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_DOCUMENT_PROCESSING_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_FINE_TUNING_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_FUNCTIONS_QUERY_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_FUNCTIONS_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_SEARCH_BATCH_QUERY_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_SEARCH_DAILY_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_PROVISIONED_THROUGHPUT_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_REST_API_USAGE_HISTORY view

USAGE_VIEWER

CORTEX_SEARCH_SERVING_USAGE_HISTORY view

USAGE_VIEWER
CREDENTIALS viewSECURITY_VIEWER

DATA_CLASSIFICATION_HISTORY view

GOVERNANCE_VIEWER

DATA_CLASSIFICATION_LATEST view

GOVERNANCE_VIEWER

DATA_METRIC_FUNCTION_EXPECTATIONS view

USAGE_VIEWER or GOVERNANCE_VIEWER

DATA_METRIC_FUNCTION_REFERENCES view

USAGE_VIEWER or GOVERNANCE_VIEWER

DATA_QUALITY_MONITORING_USAGE_HISTORY view

USAGE_VIEWER

DATA_TRANSFER_HISTORY view

USAGE_VIEWER

DATABASE_STORAGE_USAGE_HISTORY view

USAGE_VIEWER
DATABASES viewOBJECT_VIEWER

DOCUMENT_AI_USAGE_HISTORY view

USAGE_VIEWER

DYNAMIC_TABLE_REFRESH_HISTORY view

USAGE_VIEWER
ELEMENT_TYPES viewOBJECT_VIEWER

EVENT_USAGE_HISTORY view

USAGE_VIEWER

EXTERNAL_ACCESS_HISTORY view

USAGE_VIEWER
FIELDS viewOBJECT_VIEWER
FILE_FORMATS viewOBJECT_VIEWER
FUNCTIONS viewOBJECT_VIEWER

GRANTS_TO_ROLES view

SECURITY_VIEWER

GRANTS_TO_SHARES view

SECURITY_VIEWER

GRANTS_TO_USERS view

SECURITY_VIEWER

HYBRID_TABLE_USAGE_HISTORY view

USAGE_VIEWER
HYBRID_TABLES viewOBJECT_VIEWER

ICEBERG_STORAGE_OPTIMIZATION_HISTORY view

USAGE_VIEWER
INDEX_COLUMNS viewOBJECT_VIEWER
INDEXES viewOBJECT_VIEWER

INGRESS_NETWORK_ACCESS_HISTORY view

SECURITY_VIEWER

INTERNAL_DATA_TRANSFER_HISTORY view

USAGE_VIEWER

INTERNAL_STAGE_NETWORK_ACCESS_HISTORY view

SECURITY_VIEWER
JOIN_POLICIES viewGOVERNANCE_VIEWER
LISTINGS viewSECURITY_VIEWER
LOAD_HISTORY viewUSAGE_VIEWER
LOGIN_HISTORY viewSECURITY_VIEWER

MASKING_POLICIES view

GOVERNANCE_VIEWER

MATERIALIZED_VIEW_REFRESH_HISTORY view

USAGE_VIEWER

METERING_DAILY_HISTORY view

USAGE_VIEWER

METERING_HISTORY view

USAGE_VIEWER

NETWORK_POLICIES view

SECURITY_VIEWER

NETWORK_RULE_REFERENCES view

SECURITY_VIEWER
NETWORK_RULES viewSECURITY_VIEWER

NOTEBOOKS_CONTAINER_RUNTIME_HISTORY view

USAGE_VIEWER

OBJECT_ACCESS_REQUEST_HISTORY view

OBJECT_VIEWER

OBJECT_DEPENDENCIES view

OBJECT_VIEWER

ACCOUNT_USAGE.ONLINE_FEATURE_TABLE_REFRESH_HISTORY

USAGE_VIEWER

OPENFLOW_USAGE_HISTORY view

USAGE_VIEWER

OUTBOUND_PRIVATELINK_ENDPOINTS view

SECURITY_VIEWER

PASSWORD_POLICIES view

SECURITY_VIEWER

PIPE_USAGE_HISTORY view

USAGE_VIEWER
PIPES viewOBJECT_VIEWER

POLICY_REFERENCES view

GOVERNANCE_VIEWER, SECURITY_VIEWER

POSTGRES_STORAGE_USAGE_HISTORY view

USAGE_VIEWER

PRIVACY_BUDGETS view

GOVERNANCE_VIEWER

PRIVACY_POLICIES view

GOVERNANCE_VIEWER
PROCEDURES viewOBJECT_VIEWER

PROJECTION_POLICIES view

GOVERNANCE_VIEWER

QUERY_ACCELERATION_ELIGIBLE view

GOVERNANCE_VIEWER

QUERY_ATTRIBUTION_HISTORY view

USAGE_VIEWER, GOVERNANCE_VIEWER
QUERY_HISTORY viewGOVERNANCE_VIEWER

QUERY_INSIGHTS view

GOVERNANCE_VIEWER

REFERENTIAL_CONSTRAINTS view

OBJECT_VIEWER

REPLICATION_GROUP_REFRESH_HISTORY view

USAGE_VIEWER

REPLICATION_GROUP_USAGE_HISTORY view

USAGE_VIEWER

REPLICATION_GROUPS view

OBJECT_VIEWER

REPLICATION_USAGE_HISTORY view

USAGE_VIEWER

RESOURCE_MONITORS view

OBJECT_VIEWER
ROLES viewSECURITY_VIEWER

ROW_ACCESS_POLICIES view

GOVERNANCE_VIEWER
SCHEMATA viewOBJECT_VIEWER

SEARCH_OPTIMIZATION_BENEFITS view

USAGE_VIEWER

SEARCH_OPTIMIZATION_HISTORY view

USAGE_VIEWER
SECRETS viewSECURITY_VIEWER

SEMANTIC_DIMENSIONS view

OBJECT_VIEWER

SEMANTIC_FACTS view

OBJECT_VIEWER

SEMANTIC_METRICS view

OBJECT_VIEWER

SEMANTIC_RELATIONSHIPS view

OBJECT_VIEWER

SEMANTIC_TABLES view

OBJECT_VIEWER

SEMANTIC_VIEWS view

OBJECT_VIEWER
SEQUENCES viewOBJECT_VIEWER

SERVERLESS_ALERT_HISTORY view

USAGE_VIEWER

SERVERLESS_TASK_HISTORY view

USAGE_VIEWER
SERVICES viewOBJECT_VIEWER

SESSION_POLICIES view

SECURITY_VIEWER
SESSIONS viewSECURITY_VIEWER
SHARES viewSECURITY_VIEWER

SNAPSHOT_OPERATION_HISTORY view --- Deprecated

OBJECT_VIEWER

SNAPSHOT_POLICIES view --- Deprecated

OBJECT_VIEWER

SNAPSHOT_SETS view --- Deprecated

OBJECT_VIEWER

SNAPSHOT_STORAGE_USAGE view --- Deprecated

OBJECT_VIEWER

SNAPSHOTS view — Deprecated

OBJECT_VIEWER

SNOWFLAKE_INTELLIGENCE_USAGE_HISTORY view

USAGE_VIEWER

SNOWPARK_CONTAINER_SERVICES_HISTORY view

USAGE_VIEWER

SNOWPIPE_STREAMING_CHANNEL_HISTORY view

USAGE_VIEWER

STAGE_STORAGE_USAGE_HISTORY view

USAGE_VIEWER
STAGES viewOBJECT_VIEWER

STORAGE_LIFECYCLE_POLICIES view

GOVERNANCE_VIEWER

STORAGE_LIFECYCLE_POLICY_HISTORY view

GOVERNANCE_VIEWER

STORAGE_REQUEST_HISTORY view

USAGE_VIEWER
STORAGE_USAGE viewUSAGE_VIEWER

TABLE_CONSTRAINTS view

OBJECT_VIEWER

TABLE_DML_HISTORY view

USAGE_VIEWER

TABLE_PRUNING_HISTORY view

USAGE_VIEWER

TABLE_QUERY_PRUNING_HISTORY view

USAGE_VIEWER

TABLE_STORAGE_METRICS view

USAGE_VIEWER
TABLES viewOBJECT_VIEWER

TAG_REFERENCES view

GOVERNANCE_VIEWER
TAGS viewOBJECT_VIEWER or GOVERNANCE_VIEWER
TASK_HISTORY viewUSAGE_VIEWER

TRUST_CENTER_FINDINGS view

SECURITY_VIEWER
USERS viewSECURITY_VIEWER
VIEWS viewOBJECT_VIEWER

WAREHOUSE_EVENTS_HISTORY view

USAGE_VIEWER

WAREHOUSE_LOAD_HISTORY view

USAGE_VIEWER

WAREHOUSE_METERING_HISTORY view

USAGE_VIEWER

READER_ACCOUNT_USAGE schema SNOWFLAKE database roles

The READER_USAGE_VIEWER SNOWFLAKE database role is granted SELECT privilege on all READER_ACCOUNT_USAGE views. As reader accounts are created by clients, the READER_USAGE_VIEWER role is expected to be granted to those roles used to monitor reader account use.

Querying the Account Usage views

This section includes considerations when querying the Account Usage views along with query examples.

Selecting columns

The Snowflake-specific views are subject to change. Avoid selecting all columns from these views. Instead, select the columns that you want. For example, if you want the name column, use SELECT name, rather than SELECT *.

Reconciling cost views

There are several Account Usage views that contain data related to the cost of compute resources, storage, and data transfers. If you are trying to reconcile these views against a corresponding view in the ORGANIZATION_USAGE schema, you must first set the timezone of the session to UTC.

For example, if you are trying to reconcile ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY to the account’s data in ORGANIZATION_USAGE.WAREHOUSE_METERING_HISTORY, you must run the following command before querying the Account Usage view:

ALTER SESSION SET TIMEZONE = UTC;

Examples

The following examples show some typical/useful queries using the views in the ACCOUNT_USAGE schema.

Note

  • These examples assume the SNOWFLAKE database and the ACCOUNT_USAGE schema are in use for the current session. The examples also assume the ACCOUNTADMIN role (or a role granted IMPORTED PRIVILEGES on the database) is in use. If they are not in use, execute the following commands before running the queries in the examples:
    USE ROLE ACCOUNTADMIN;
    
    USE SCHEMA snowflake.account_usage;

Examples: User login metrics

Average number of seconds between failed login attempts by user (month-to-date):

select user_name,
       count(*) as failed_logins,
       avg(seconds_between_login_attempts) as average_seconds_between_login_attempts
from (
      select user_name,
             timediff(seconds, event_timestamp, lead(event_timestamp)
                 over(partition by user_name order by event_timestamp)) as seconds_between_login_attempts
      from login_history
      where event_timestamp > date_trunc(month, current_date)
      and is_success = 'NO'
     )
group by 1
order by 3;

Failed logins by user (month-to-date):

select user_name,
       sum(iff(is_success = 'NO', 1, 0)) as failed_logins,
       count(*) as logins,
       sum(iff(is_success = 'NO', 1, 0)) / nullif(count(*), 0) as login_failure_rate
from login_history
where event_timestamp > date_trunc(month, current_date)
group by 1
order by 4 desc;

Failed logins by user and connecting client (month-to-date):

select reported_client_type,
       user_name,
       sum(iff(is_success = 'NO', 1, 0)) as failed_logins,
       count(*) as logins,
       sum(iff(is_success = 'NO', 1, 0)) / nullif(count(*), 0) as login_failure_rate
from login_history
where event_timestamp > date_trunc(month, current_date)
group by 1,2
order by 5 desc;

Examples: Warehouse performance

This query calculates virtual warehouse performance metrics such as throughput and latency for 15-minute time intervals over the course of one day.

In the code sample below, you can replace CURRENT_WAREHOUSE() with the name of a warehouse to calculate metrics for that warehouse. In addition, change the time_from and time_to dates in the WITH clause to specify the time period.

WITH
params AS (
SELECT
    CURRENT_WAREHOUSE() AS warehouse_name,
    '2021-11-01' AS time_from,
    '2021-11-02' AS time_to
),

jobs AS (
SELECT
    query_id,
    time_slice(start_time::timestamp_ntz, 15, 'minute','start') as interval_start,
    qh.warehouse_name,
    database_name,
    query_type,
    total_elapsed_time,
    compilation_time AS compilation_and_scheduling_time,
    (queued_provisioning_time + queued_repair_time + queued_overload_time) AS queued_time,
    transaction_blocked_time,
    execution_time
FROM snowflake.account_usage.query_history qh, params
WHERE
    qh.warehouse_name = params.warehouse_name
AND start_time >= params.time_from
AND start_time <= params.time_to
AND execution_status = 'SUCCESS'
AND query_type IN ('SELECT','UPDATE','INSERT','MERGE','DELETE')
),

interval_stats AS (
SELECT
    query_type,
    interval_start,
    COUNT(DISTINCT query_id) AS numjobs,
    MEDIAN(total_elapsed_time)/1000 AS p50_total_duration,
    (percentile_cont(0.95) within group (order by total_elapsed_time))/1000 AS p95_total_duration,
    SUM(total_elapsed_time)/1000 AS sum_total_duration,
    SUM(compilation_and_scheduling_time)/1000 AS sum_compilation_and_scheduling_time,
    SUM(queued_time)/1000 AS sum_queued_time,
    SUM(transaction_blocked_time)/1000 AS sum_transaction_blocked_time,
    SUM(execution_time)/1000 AS sum_execution_time,
    ROUND(sum_compilation_and_scheduling_time/sum_total_duration,2) AS compilation_and_scheduling_ratio,
    ROUND(sum_queued_time/sum_total_duration,2) AS queued_ratio,
    ROUND(sum_transaction_blocked_time/sum_total_duration,2) AS blocked_ratio,
    ROUND(sum_execution_time/sum_total_duration,2) AS execution_ratio,
    ROUND(sum_total_duration/numjobs,2) AS total_duration_perjob,
    ROUND(sum_compilation_and_scheduling_time/numjobs,2) AS compilation_and_scheduling_perjob,
    ROUND(sum_queued_time/numjobs,2) AS queued_perjob,
    ROUND(sum_transaction_blocked_time/numjobs,2) AS blocked_perjob,
    ROUND(sum_execution_time/numjobs,2) AS execution_perjob
FROM jobs
GROUP BY 1,2
ORDER BY 1,2
)
SELECT * FROM interval_stats;

Note

Analyze different statement types separately (e.g., SELECT statements independent of INSERT or DELETE or other statements).

  • The NUMJOBS value represents the throughput for that time interval.
  • The P50_TOTAL_DURATION (median) and P95_TOTAL_DURATION (peak) values represent latency.
  • The SUM_TOTAL_DURATION is the sum of the SUM_<job_stage>_TIME values for the different job stages (COMPILATION_AND_SCHEDULING, QUEUED, BLOCKED, EXECUTION).
  • Analyze the <job_stage>_RATIO values when the load (NUMJOBS) increases. Look for ratio changes or deviations from the average.
  • If the QUEUED_RATIO is high, there might not be sufficient capacity in the warehouse. Add more clusters or increase the warehouse size.

Examples: Warehouse credit usage

Credits used by each warehouse in your account (month-to-date):

select warehouse_name,
       sum(credits_used) as total_credits_used
from warehouse_metering_history
where start_time >= date_trunc(month, current_date)
group by 1
order by 2 desc;

Credits used over time by each warehouse in your account (month-to-date):

select start_time::date as usage_date,
       warehouse_name,
       sum(credits_used) as total_credits_used
from warehouse_metering_history
where start_time >= date_trunc(month, current_date)
group by 1,2
order by 2,1;

Examples: Data storage usage

Billable terabytes stored in your account over time:

select date_trunc(month, usage_date) as usage_month
  , avg(storage_bytes + stage_bytes + failsafe_bytes) / power(1024, 4) as billable_tb
from storage_usage
group by 1
order by 1;

Examples: User query totals and execution times

Total jobs executed in your account (month-to-date):

select count(*) as number_of_jobs
from query_history
where start_time >= date_trunc(month, current_date);

Total jobs executed by each warehouse in your account (month-to-date):

select warehouse_name,
       count(*) as number_of_jobs
from query_history
where start_time >= date_trunc(month, current_date)
group by 1
order by 2 desc;

Average query execution time by user (month-to-date):

select user_name,
       avg(execution_time) as average_execution_time
from query_history
where start_time >= date_trunc(month, current_date)
group by 1
order by 2 desc;

Average query execution time by query type and warehouse size (month-to-date):

select query_type,
       warehouse_size,
       avg(execution_time) as average_execution_time
from query_history
where start_time >= date_trunc(month, current_date)
group by 1,2
order by 3 desc;

Examples: Obtain a query count for every login event

Join columns from LOGIN_HISTORY, QUERY_HISTORY, and SESSIONS to obtain a query count for each user login event.

Note

The SESSIONS view records information starting on July 20-21, 2020, therefore the query result will only contain overlapping information for each of the three views starting from this date.

select l.user_name,
       l.event_timestamp as login_time,
       l.client_ip,
       l.reported_client_type,
       l.first_authentication_factor,
       l.second_authentication_factor,
       count(q.query_id)
from snowflake.account_usage.login_history l
join snowflake.account_usage.sessions s on l.event_id = s.login_event_id
join snowflake.account_usage.query_history q on q.session_id = s.session_id
group by 1,2,3,4,5,6
order by l.user_name
;