GET_QUERY_OPERATOR_STATS

functionsupportedQueries & DML

docs.snowflake.com ↗

System functionsTable functions

Returns statistics about individual query operators within a query that has completed. You can run this function for any completed query that was executed in the past 14 days. You can use this information to understand the structure of a query and identify query operators — for example, the join operator — that cause performance problems. For example, you can use this information to determine which operators are consuming the most resources. As another example, you can use this function to identify joins that have more output rows than input rows, which can be a sign of an “exploding” join; for example, an unintended Cartesian product. These statistics are also available in the query profile tab in Snowsight. The GET_QUERY_OPERATOR_STATS() function makes the same information available via a programmatic interface. For more information about finding problematic query operators, see Common query problems identified by Query Profile.

Syntax

GET_QUERY_OPERATOR_STATS( <query_id> )

Parameters

NameRequiredDescription
query_idrequiredThe ID of a query. You can use: A string literal (a string surrounded by single quotes). A session variable containing a query ID. The return value from a call to the LAST_QUERY_ID function.

Returns

The GET_QUERY_OPERATOR_STATS function is a table function. It returns rows with statistics about each query operator in the query. For more information, see the Usage notes and Output sections below.

Usage notes

Output

The function returns the following columns: Column name | Data type | Description QUERY_ID | VARCHAR | The query ID, which is an internal, system-generated identifier for the SQL statement. STEP_ID | NUMBER(38, 0) | Identifier of the step in the query plan. OPERATOR_ID | NUMBER(38, 0) | The operator’s identifier. This is unique within the query. Values start at 0. PARENT_OPERATORS | ARRAY containing one or more NUMBER(38, 0) | Identifiers of the parent operators for this operator, or NULL if this is the final operator in the query plan (which is usually the Result operator). OPERATOR_TYPE | VARCHAR | The type of query operator; for example, TableScan or Filter. OPERATOR_STATISTICS | VARIANT containing an OBJECT | Statistics about the operator (for example, the number of output rows from the operator). EXECUTION_TIME_BREAKDOWN | VARIANT containing an OBJECT | Information about the execution time of the operator. OPERATOR_ATTRIBUTES | VARIANT containing an OBJECT | Information about the operator. This information depends on the operator type. If there is no information for the specific column for the operator, the value is NULL. Three of these columns contain OBJECTs. Each object contains key/value pairs. The tables below describe the keys in these objects. The fields in the OBJECTs for the OPERATOR_STATISTICS column provide additional information about the operator. The information can include: Key | Nested key (if applicable) | Data type | Description dml | | | Statistics for Data Manipulation Language (DML) queries. | number_of_rows_inserted | DOUBLE | Number of rows inserted into a table or tables. | number_of_rows_updated | DOUBLE | Number of rows updated in a table. | number_of_rows_deleted | DOUBLE | Number of rows deleted from a table. | number_of_rows_unloaded | DOUBLE | Number of rows unloaded during data export. extension_functions | | | Information about calls to extension functions. If the value of a field is zero, then the field is not displayed. | Java UDF handler load time | DOUBLE | Amount of time for the Java UDF handler to load. | Total Java UDF handler invocations | DOUBLE | Number of times the Java UDF handler is invoked. | Max Java UDF handler execution time | DOUBLE | Maximum amount of time for the Java UDF handler to execute. | Avg Java UDF handler execution time | DOUBLE | Average amount of time to execute the Java UDF handler. | Java UDTF process() invocations | DOUBLE | Number of times the Java UDTF process method was invoked. | Java UDTF process() execution time | DOUBLE | Amount of time to execute the Java UDTF process. | Avg Java UDTF process() execution time | DOUBLE | Average amount of time to execute the Java UDTF process. | Java UDTF's constructor invocations | DOUBLE | Number of times the Java UDTF constructor was invoked. | Java UDTF's constructor execution time | DOUBLE | Amount of time to execute the Java UDTF constructor. | Avg Java UDTF's constructor execution time | DOUBLE | Average amount of time to execute the Java UDTF constructor. | Java UDTF endPartition() invocations | DOUBLE | Number of times the Java UDTF endPartition method was invoked. | Java UDTF endPartition() execution time | DOUBLE | Amount of time to execute the Java UDTF endPartition method. | Avg Java UDTF endPartition() execution time | DOUBLE | Average amount of time to execute the Java UDTF endPartition method. | Max Java UDF dependency download time | DOUBLE | Maximum amount of time to download the Java UDF dependencies. | Max JVM memory usage | DOUBLE | Peak memory usage as reported by the JVM. | Java UDF inline code compile time in ms | DOUBLE | Compile time for the Java UDF inline code. | Total Python UDF handler invocations | DOUBLE | Number of times the Python UDF handler was invoked. | Total Python UDF handler execution time | DOUBLE | Total execution time for the Python UDF handler. | Avg Python UDF handler execution time | DOUBLE | Average amount of time to execute the Python UDF handler. | Python sandbox max memory usage | DOUBLE | Peak memory usage by the Python sandbox environment. | Avg Python env creation time: Download and install packages | DOUBLE | Average amount of time to create the Python environment, including downloading and installing packages. | Conda solver time | DOUBLE | Amount of time to run the Conda solver to solve Python packages. | Conda env creation time | DOUBLE | Amount of time to create the Python environment. | Python UDF initialization time | DOUBLE | Amount of time to initialize the Python UDF. | Number of external file bytes read for UDFs | DOUBLE | Number of external file bytes read for UDFs. | Number of external files accessed for UDFs | DOUBLE | Number of external files accessed for UDFs. external_functions | | | Information about calls to external functions. If the value of a field — for example retries_due_to_transient_errors — is zero, then the field is not displayed. | total_invocations | DOUBLE | Number of times that an external function was called. This number can be different from the number of external function calls in the text of the SQL statement because of the number of batches that rows are divided into, the number of retries if there are transient network problems, and so on. | rows_sent | DOUBLE | Number of rows sent to external functions. | rows_received | DOUBLE | Number of rows received back from external functions. | bytes_sent (x-region) | DOUBLE | Number of bytes sent to external functions. If the key includes (x-region), the data was sent across regions, which can impact billing. | bytes_received (x-region) | DOUBLE | Number of bytes received from external functions. If the key includes (x-region), the data was sent across regions, which can impact billing. | retries_due_to_transient_errors | DOUBLE | Number of retries because of transient errors. | average_latency_per_call | DOUBLE | Average amount of time per invocation (call) in milliseconds between the time Snowflake sent the data and received the returned data. | http_4xx_errors | INTEGER | Total number of HTTP requests that returned a 4xx status code. | http_5xx_errors | INTEGER | Total number of HTTP requests that returned a 5xx status code. | average_latency | DOUBLE | Average latency for successful HTTP requests. | avg_throttle_latency_overhead | DOUBLE | Average overhead per successful request because of a slowdown caused by throttling (HTTP 429). | batches_retried_due_to_throttling | DOUBLE | Number of batches that were retried because of HTTP 429 errors. | latency_per_successful_call_(p50) | DOUBLE | 50th percentile latency for successful HTTP requests. 50 percent of all successful requests took less than this time to complete. | latency_per_successful_call_(p90) | DOUBLE | 90th percentile latency for successful HTTP requests. 90 percent of all successful requests took less than this time to complete. | latency_per_successful_call_(p95) | DOUBLE | 95th percentile latency for successful HTTP requests. 95 percent of all successful requests took less than this time to complete. | latency_per_successful_call_(p99) | DOUBLE | 99th percentile latency for successful HTTP requests. 99 percent of all successful requests took less than this time to complete. input_rows | | INTEGER | Number of input rows. This can be missing for an operator with no input edges from other operators. io | | | Information about the I/O (input/output) operations performed during the query. | scan_progress | DOUBLE | Percentage of data scanned for a given table so far. | bytes_scanned | DOUBLE | Number of bytes scanned so far. | percentage_scanned_from_cache | DOUBLE | Percentage of data scanned from the local disk cache. | bytes_written | DOUBLE | Bytes written; for example, when loading into a table. | bytes_written_to_result | DOUBLE | Bytes written to a result object. For example, SELECT * FROM ... would produce a set of results in tabular format representing each field in the selection. In general, the results object represents whatever is produced as a result of the query, and bytes_written_to_result represents the size of the returned result. | bytes_read_from_result | DOUBLE | Bytes read from a result object. | external_bytes_scanned | DOUBLE | Bytes read from an external object; for example, a stage. network | network_bytes | DOUBLE | Amount of data sent over the network. output_rows | | INTEGER | Number of output rows. This can be missing for the operator that returns the results to the user; which is usually the RESULT operator. pruning | | | Information on table pruning. | partitions_pruned_by_snowflake_optima | DOUBLE | Number of partitions pruned by Snowflake Optima. | partitions_scanned | DOUBLE | Number of partitions scanned so far. | partitions_total | DOUBLE | Total number of partitions in a given table. spilling | | | Information about disk usage for operations in which intermediate results do not fit in memory. | bytes_spilled_remote_storage | DOUBLE | Volume of data spilled to remote disk. | bytes_spilled_local_storage | DOUBLE | Volume of data spilled to local disk. search_optimization | | | Information about queries that use the search optimization service. | partitions_pruned_by_search_optimization | DOUBLE | Number of partitions pruned by search optimization. | partitions_pruned_by_search_optimization_and_snowflake_optima | DOUBLE | Number of partitions pruned by search optimization and Snowflake Optima. The fields in the OBJECTs for the EXECUTION_TIME_BREAKDOWN column are shown below. Key | Data type | Description overall_percentage | DOUBLE | Percentage of the total query time spent by this operator. initialization | DOUBLE | Time spent setting up query processing. processing | DOUBLE | Time spent processing the data by the CPU. synchronization | DOUBLE | Time spent synchronizing activities between participating processes. local_disk_io | DOUBLE | Time during which processing was blocked while waiting for local disk access. remote_disk_io | DOUBLE | Time during which processing was blocked while waiting for remote disk access. network_communication | DOUBLE | Time during which processing was waiting for network data transfer. Each output row describes one operator in the query. The following table shows the possible types of operators; for example, the Filter operator. For each type of operator, the table shows the possible attributes; for example, the expression used to filter the rows. The operator attributes are stored in the OPERATOR_ATTRIBUTES column, which is of type VARIANT and contains an OBJECT. The OBJECT contains key/value pairs. Each key corresponds to one attribute of the operator. Operator name | Key | Data type | Description Aggregate | | | | functions | ARRAY of VARCHAR | List of functions computed. | grouping_keys | ARRAY of VARCHAR | Group-by expression. CartesianJoin | | | | additional_join_condition | VARCHAR | Non-equality join expression. | equality_join_condition | VARCHAR | Equality join expression. | join_type | VARCHAR | Type of join (INNER). Delete | table_name | VARCHAR | Name of updated table. ExternalScan | | | | stage_name | VARCHAR | The name of the stage from which the data is read. | stage_type | VARCHAR | The type of the stage. Filter | filter_condition | VARCHAR | The expression used to filter data. Flatten | input | VARCHAR | Input expression used to flatten data. Generator | | | | row_count | NUMBER | Value of the input parameter ROWCOUNT. | time_limit | NUMBER | Value of the input parameter TIMELIMIT. GroupingSets | | | | functions | ARRAY of VARCHAR | List of functions computed. | key_sets | ARRAY of VARCHAR | List of grouping sets. Insert | | | | input_expression | VARCHAR | Which expressions are inserted. | table_names | ARRAY of VARCHAR | List of table names to which records are added. InternalObject | object_name | VARCHAR | Name of the accessed object. Join | | | | additional_join_condition | VARCHAR | Non-equality join expression. | equality_join_condition | VARCHAR | Equality join expression. | join_type | VARCHAR | Type of join (INNER, OUTER, LEFT JOIN, etc.). JoinFilter | join_id | NUMBER | Operator id of the join used to identify tuples that can be filtered out. Merge | table_name | VARCHAR | Name of updated table. Pivot | | | | grouping_keys | ARRAY of VARCHAR | Remaining columns on which the results are aggregated. | pivot_column | ARRAY of VARCHAR | Resulting columns of pivot values. Result | expressions | ARRAY of VARCHAR | List of expressions produced. Sort | sort_keys | ARRAY of VARCHAR | Expression defining the sorting order. SortWithLimit | | | | offset | NUMBER | Position in the ordered sequence from which produced tuples are emitted. | rows | NUMBER | Number of rows produced. | sort_keys | ARRAY of VARCHAR | Expression defining the sorting order. TableScan | | | | columns | ARRAY of VARCHAR | List of scanned columns. | extracted_variant_paths | ARRAY of VARCHAR | List of paths extracted from variant columns. | table_alias | VARCHAR | Alias of table being accessed. | table_name | VARCHAR | Name of table being accessed. Unload | location | VARCHAR | Stage where data is saved. Unpivot | expressions | ARRAY of VARCHAR | Output columns of the unpivot query. Update | table_name | VARCHAR | Name of updated table. ValuesClause | | | | value_count | NUMBER | Number of produced values. | values | VARCHAR | List of values. WindowFunction | functions | ARRAY of VARCHAR | List of functions computed. WithClause | name | VARCHAR | Alias of WITH clause. If an operator is not listed, no attributes are produced, and the value is reported as {}. Note - The following operators do not have any operator attributes and therefore are not included in the table of OPERATOR_ATTRIBUTES: UnionAll - ExternalFunction