Schema:

ORGANIZATION_USAGE

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

COLUMN_QUERY_PRUNING_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.

Use this Organization Usage view to gain a better understanding of data access patterns during query execution, including some column-level details, such as the “access type” and candidate search optimization expressions that are potentially beneficial.

You can use this view in combination with the TABLE_QUERY_PRUNING_HISTORY view. For example, you can identify access to target tables by using the TABLE_QUERY_PRUNING_HISTORY view, then identify frequently used columns on those tables by using the COLUMN_QUERY_PRUNING_HISTORY view.

Each row in this view represents the query pruning history for a specific column within a given time interval. The data is aggregated per column, per table, per interval, and includes metrics such as the number of queries executed, partitions scanned, partitions pruned, rows scanned, rows pruned, and rows matched.

See also TABLE_PRUNING_HISTORY view and Query Pruning.

Columns

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
INTERVAL_START_TIMETIMESTAMP_LTZStart of the time range (on the hour mark) during which the queries were executed and completed.
INTERVAL_END_TIMETIMESTAMP_LTZEnd of the time range (on the hour mark) during which the queries were executed and completed.
TABLE_IDNUMBERInternal/system-generated identifier for the table that was queried.
TABLE_NAMEVARCHARName of the table that was queried.
SCHEMA_IDNUMBERInternal/system-generated identifier for the schema that contains the table that was queried.
SCHEMA_NAMEVARCHARName of the schema that contains the table that was queried.
DATABASE_IDNUMBERInternal/system-generated identifier for the database that contains the table that was queried.
DATABASE_NAMEVARCHARName of the database that contains the table that was queried.
WAREHOUSE_IDNUMBERInternal/system-generated identifier for the warehouse that was used to run the queries.
WAREHOUSE_NAMEVARCHARName of the warehouse that ran the queries.
QUERY_HASHVARCHARThe hash value computed based on the canonicalized SQL text.
QUERY_PARAMETERIZED_HASHVARCHARThe hash value computed based on the parameterized query.
COLUMN_IDNUMBERInternal/system-generated identifier for the column accessed from the table that was queried.
COLUMN_NAMEVARCHARName of the column accessed from the table that was queried.
VARIANT_PATHVARCHARPath to the semi-structured data being accessed (if applicable). NULL if the column accessed does not have a semi-structured data type.
ACCESS_TYPEVARCHARType of access performed on the column (WHERE or JOIN condition).
NUM_QUERIESNUMBERNumber of queries executed in this time range with this specific QUERY_HASH value, using this warehouse, accessing this column (and variant path if applicable) on this table with this type of access.
AGGREGATE_QUERY_ELAPSED_TIMENUMBERTotal elapsed time (in milliseconds) for queries defined by NUM_QUERIES. This total includes queueing and other time not associated with compilation and execution.
AGGREGATE_QUERY_COMPILATION_TIMENUMBERTotal compilation time (in milliseconds) for queries defined by NUM_QUERIES.
AGGREGATE_QUERY_EXECUTION_TIMENUMBERTotal execution time (in milliseconds) for queries defined by NUM_QUERIES.
PARTITIONS_SCANNEDNUMBERNumber of partitions scanned on this table for queries defined by NUM_QUERIES.
PARTITIONS_PRUNEDNUMBERNumber of partitions pruned on this table for queries defined by NUM_QUERIES. These partitions were eliminated during query processing and not scanned, improving the efficiency of the query.
ROWS_SCANNEDNUMBERNumber of rows scanned on this table for queries defined by NUM_QUERIES.
ROWS_PRUNEDNUMBERNumber of rows pruned on this table for queries defined by NUM_QUERIES. These rows were eliminated during query processing and not scanned, improving the efficiency of the query.
ROWS_MATCHEDNUMBERNumber of rows that matched the WHERE clause filters while scanning this table for the queries defined by NUM_QUERIES.
SEARCH_OPTIMIZATION_SUPPORTED_EXPRESSIONSARRAYList of supported search optimization expressions on this column that could potentially speed up scanning this table for the queries defined by NUM_QUERIES.

Usage notes

  • Latency for the view may be up to 6 hours.

  • Data is retained for 1 year.

  • This view does not include pruning information for hybrid tables.

  • The ACCESS_TYPE column contains one of the following values:

    • WHERE: The column is used in a filter condition in the WHERE clause.
    • JOIN: The column is used in a condition for a JOIN operation.
  • The access behavior shown in this view reflects the actual query plan that was executed, which might be different from the original query text. For example, if a HAVING clause does not reference aggregated results produced by the GROUP BY clause, it might be optimized and rewritten as a WHERE clause, and the ACCESS_TYPE value will be WHERE.

  • For complex filtering conditions that can’t benefit from a pushdown optimization, rows might not be filtered out during the table scan operation, even if they do not match the filtering condition. Therefore, these rows are counted in the ROWS_MATCHED value.

  • Currently, the SEARCH_OPTIMIZATION_SUPPORTED_EXPRESSIONS column only suggests the EQUALITY and SUBSTRING search methods.

  • This view retains data for the 1,000 longest-running table scans per query. Only extremely complex queries exceed this number of scans so data is rarely omitted.