Schema:

ORGANIZATION_USAGE

For guidance on query performance when using organization-wide usage views, see Performance (Organization Usage).

QUERY_METERING_HISTORY view

Important

This view is only available in the organization account. For more information, see Premium views in the organization account.

Organization Usage performance

When you query a specific view in the SNOWFLAKE.ORGANIZATION_USAGE schema, follow the organization-wide guidance in Performance (Organization Usage): bound every scan on history views, list columns explicitly, and use the time filter column table plus worked SQL and anti-patterns there.

Note

Coming soon: The QUERY_METERING_HISTORY view is not yet available in the ORGANIZATION_USAGE schema. Use QUERY_METERING_HISTORY view in ACCOUNT_USAGE for per-query credit usage on adaptive warehouses.

When available, the query metering history view (QUERY_METERING_HISTORY) will return per-query credit usage for queries run on adaptive warehouses across accounts in your organization.

Columns

Several columns can be NULL until the query completes. For details, see usage notes.

Organization-level columns

Column NameData TypeDescription
ORGANIZATION_NAMEVARCHARName of the organization.
ACCOUNT_LOCATORVARCHARSystem-generated identifier for the account.
ACCOUNT_NAMEVARCHARUser-defined identifier for the account.

Additional columns

Column nameData typeDescription
QUERY_IDVARCHARInternal/system-generated identifier for the SQL statement.
WAREHOUSE_IDNUMBERInternal/system-generated identifier for the warehouse that the query was executed on.
WAREHOUSE_NAMEVARCHARName of the warehouse that the query executed on.
QUERY_METERING_HOURTIMESTAMP_LTZStart of the metering hour window this row represents.
QUERY_START_TIMETIMESTAMP_LTZTime when query execution started (in the local time zone).
QUERY_END_TIMETIMESTAMP_LTZTime when query execution ended (in the local time zone). NULL until the query completes; see usage notes.
PARENT_QUERY_IDVARCHARQuery ID of the parent query. NULL until the query completes, or NULL if the query does not have a parent.
ROOT_QUERY_IDVARCHARQuery ID of the topmost query in the chain. NULL until the query completes, or NULL if the query is a standalone query (not part of a chain).
USER_IDNUMBERInternal/system-generated identifier for the user who issued the query.
USER_NAMEVARCHARUser who issued the query.
ROLE_NAMEVARCHARRole that issued the query.
QUERY_HASHVARCHARThe hash value computed based on the canonicalized SQL text.
QUERY_PARAMETERIZED_HASHVARCHARThe hash value computed based on the parameterized query.
QUERY_TAGVARCHARQuery tag set for this statement through the QUERY_TAG session parameter.
CREDITS_USED_COMPUTENUMBERNumber of credits used for compute for this query in this metering hour.
CREDITS_USED_CLOUD_SERVICESNUMBERNumber of credits used for cloud services for this query in this metering hour.
CREDITS_USEDNUMBERTotal number of credits used for this query in this metering hour.

Usage notes

  • When this view is available in ORGANIZATION_USAGE, latency for the view may be up to 24 hours. Charges accrued by a job may take up to 24 hours to appear in the view.
  • This view includes per-query credit usage for queries run on adaptive warehouses.

  • Each query can have multiple rows in this view: one row per metering hour while the query runs. Use QUERY_METERING_HOUR to identify the metering window for each row.

  • While a query is running, each metering-hour row is refreshed in-place with updated credit usage. When the query finishes, the final row for that metering hour is written and no longer changes.

  • Until a query completes, the following columns can be NULL on in-progress rows: WAREHOUSE_NAME, QUERY_START_TIME, QUERY_END_TIME, PARENT_QUERY_ID, ROOT_QUERY_ID, USER_NAME, ROLE_NAME, QUERY_HASH, QUERY_PARAMETERIZED_HASH, and QUERY_TAG. After the query completes, PARENT_QUERY_ID and ROOT_QUERY_ID remain NULL when the query has no parent or is not part of a chain.

  • For aggregated warehouse credit usage (all warehouse types), use WAREHOUSE_METERING_HISTORY view.

  • For per-query compute cost attribution on standard warehouses, use QUERY_ATTRIBUTION_HISTORY view.

Data freshness examples

Query runs for one hour

A query runs for an entire hour. The view contains one row for that metering hour. While the query is running, that row is updated in-place with current credit usage. When the query finishes at the end of the hour, that row is final.

Query runs for multiple hours

A query runs across multiple hours. The view contains one row per metering hour (QUERY_METERING_HOUR). Each row follows the same in-place refresh behavior while the query is still running.

  • The usage notes below describe row refresh, in-progress NULL columns, and data freshness for query metering. They apply to this organization view when it is available.

  • When this view is available, the QUERY_METERING_HISTORY view in the ACCOUNT_USAGE schema will contain the same columns as the QUERY_METERING_HISTORY view in the ORGANIZATION_USAGE schema, except for the organization-level columns. For sample queries, see Examples. Replace SNOWFLAKE.ACCOUNT_USAGE with SNOWFLAKE.ORGANIZATION_USAGE in the queries to return organization-level results.