카테고리:

시스템 함수 (쿼리 정보) , 테이블 함수

GET_QUERY_OPERATOR_STATS

완료한 쿼리 내의 개별 쿼리 연산자에 대한 통계를 반환합니다. 지난 14일간 실행된 모든 완료된 쿼리에 대해 이 함수를 실행할 수 있습니다.

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.

이러한 통계는 Snowsight 의 쿼리 프로필 탭에서도 사용할 수 있습니다. GET_QUERY_OPERATOR_STATS() 함수는 프로그래밍 방식의 인터페이스를 통해 동일한 정보를 제공합니다.

문제가 있는 쿼리 연산자를 찾는 방법에 대한 자세한 내용은 쿼리 프로필을 통해 확인된 일반 쿼리 문제 섹션을 참조하십시오.

구문

GET_QUERY_OPERATOR_STATS( <query_id> )
Copy

인자

query_id

쿼리의 ID입니다. 다음을 사용할 수 있습니다.

  • 문자열 리터럴(작은따옴표로 묶인 문자열).

  • 쿼리 ID를 포함하는 세션 변수.

  • LAST_QUERY_ID 함수에 대한 호출의 반환 값.

반환

GET_QUERY_OPERATOR_STATS 함수는 테이블 함수 입니다. 쿼리의 각 쿼리 연산자에 대한 통계가 포함된 행을 반환합니다. 자세한 내용은 아래의 사용법 노트출력 섹션을 참조하십시오.

사용법 노트

  • This function returns statistics only for queries that have completed.

  • 쿼리를 실행한 웨어하우스에 대한 OPERATE 또는 MONITOR 권한이 있어야 합니다.

  • This function provides detailed statistics about each query operator used in the specified query. The following list shows the possible query operators:

    • Aggregate: 입력을 그룹화하고 집계 함수를 계산합니다.

    • CartesianJoin: 특수한 조인 유형.

    • Delete: 테이블에서 레코드를 제거합니다.

    • ExternalFunction: 외부 함수에 의한 처리를 나타냅니다.

    • ExternalScan: 스테이지 오브젝트에 저장된 데이터에 대한 액세스를 나타냅니다.

    • Filter: 행을 필터링하는 작업을 나타냅니다.

    • Flatten: VARIANT 레코드를 처리하여 지정된 경로에서 평면화할 수 있습니다.

    • Generator: Generates records by using the TABLE(GENERATOR(…)) construct.

    • GroupingSets: Represents constructs, such as GROUPING SETS, ROLLUP, and CUBE.

    • Insert: INSERT 또는 COPY 작업을 통해 테이블에 레코드를 추가합니다.

    • InternalObject: Represents access to an internal data object; for example, in an Information Schema or the result of a previous query.

    • Join: 지정된 조건에서 두 입력을 결합합니다.

    • JoinFilter: 쿼리 계획에서 더 이상 조인 조건과 일치하지 않는 것으로 식별될 수 있는 튜플을 제거하는 특수 필터링 작업입니다.

    • Merge: 테이블에 대한 MERGE 연산을 수행합니다.

    • Pivot: 열의 고유 값을 여러 열로 변환하고 필요한 집계를 수행합니다.

    • Result: 쿼리 결과를 반환합니다.

    • Sort: 지정된 식에서 입력을 정렬합니다.

    • SortWithLimit: 일반적으로 ORDER BY ... LIMIT ... OFFSET ... 구문의 결과인 정렬 후 입력 시퀀스의 일부를 생성합니다.

    • TableScan: 단일 테이블에 대한 액세스를 나타냅니다.

    • UnionAll: 두 입력을 연결합니다.

    • Unload: 테이블의 데이터를 스테이지의 파일로 내보내는 COPY 작업을 나타냅니다.

    • Unpivot: 열을 행으로 변환하여 테이블을 회전합니다.

    • Update: 테이블에서 레코드를 업데이트합니다.

    • ValuesClause: VALUES 절과 함께 제공되는 값 목록입니다.

    • WindowFunction: 윈도우 함수를 계산합니다.

    • WithClause: SELECT 문의 본문에 선행하며 하나 이상의 CTE를 정의합니다.

    • WithReference: WITH 절의 인스턴스입니다.

  • 이 정보는 테이블로 반환됩니다. 테이블의 각 행은 하나의 연산자에 해당합니다. 이 행에는 해당 연산자에 대한 실행 분석 및 쿼리 통계가 포함됩니다.

    이 행에는 연산자 특성 도 나열될 수 있습니다(이러한 특성은 연산자 유형에 따라 다름).

    Statistics that break down query execution time are expressed as a percentage of the total query execution time.

    특정 통계에 대한 자세한 내용은 이 항목의 출력 섹션을 참조하십시오.

  • 이 함수는 테이블 함수이므로 FROM 절에서 사용해야 하며 TABLE() 로 래핑해야 합니다. 예:

    SELECT * FROM TABLE(GET_QUERY_OPERATOR_STATS(last_query_id()));
    
    Copy
  • 특정 쿼리(즉, 특정 UUID)의 각 개별 실행에 대해 이 함수는 결정적이며, 매번 똑같은 값을 반환합니다.

    하지만 같은 쿼리 텍스트의 다른 실행에 대해 이 함수는 다른 런타임 통계를 반환할 수 있습니다. 통계는 많은 요인에 따라 달라집니다. 다음 요인은 실행에 중대한 영향을 미치며 따라서 이 함수에서 반환되는 통계에도 중대한 영향을 미칠 수 있습니다.

    • 데이터의 양.

    • 구체화된 뷰 의 가용성과 이러한 구체화된 뷰를 마지막으로 새로 고친 이후 데이터에 대한 변경 사항(있는 경우).

    • 클러스터링 의 존재 또는 부재.

    • 이전에 캐시된 데이터의 존재 또는 부재.

    • 가상 웨어하우스의 크기.

    값은 사용자의 쿼리와 데이터 외부 요인의 영향을 받을 수도 있습니다. 이러한 요인은 대개 작습니다. 이러한 요인에는 다음이 포함됩니다.

    • 가상 웨어하우스 초기화 시간.

    • 외부 함수 사용 시의 대기 시간.

출력

이 함수는 다음 열을 반환합니다.

Column name

Data type

설명

QUERY_ID

VARCHAR

SQL 문에 대한 내부의 시스템 생성 식별자인 쿼리 ID.

STEP_ID

NUMBER(38, 0)

쿼리 계획의 단계 식별자.

OPERATOR_ID

NUMBER(38, 0)

연산자의 식별자. 이것은 쿼리 내에서 고유합니다. 값은 0에서 시작합니다.

PARENT_OPERATORS

하나 이상의 NUMBER를 포함한 ARRAY(38, 0)

이 연산자에 대한 상위 연산자의 식별자, 또는 쿼리 계획의 마지막 연산자(보통은 Result 연산자)인 경우에는 NULL입니다.

OPERATOR_TYPE

VARCHAR

The type of query operator; for example, TableScan or Filter.

OPERATOR_STATISTICS

OBJECT를 포함하는 VARIANT

Statistics about the operator (for example, the number of output rows from the operator).

EXECUTION_TIME_BREAKDOWN

OBJECT를 포함하는 VARIANT

연산자의 실행 시간에 대한 정보.

OPERATOR_ATTRIBUTES

OBJECT를 포함하는 VARIANT

Information about the operator. This information depends on the operator type.

연산자의 특정 열에 대한 정보가 없는 경우 값은 NULL입니다.

Three of these columns contain OBJECTs. Each object contains key/value pairs. The tables below describe the keys in these objects.

OPERATOR_STATISTICS

OPERATOR_STATISTICS 열의 OBJECTs에 있는 필드에서는 연산자에 대한 추가 정보를 제공합니다. 정보에는 다음이 포함될 수 있습니다.

Nested key (if applicable)

Data type

설명

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

4xx 상태 코드를 반환한 총 HTTP 요청 수입니다.

http_5xx_errors

INTEGER

5xx 상태 코드를 반환한 총 HTTP 요청 수입니다.

average_latency

DOUBLE

성공적인 HTTP 요청을 위한 평균 대기 시간입니다.

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

성공적인 HTTP 요청의 50번째 백분위수 대기 시간입니다. 성공적인 모든 요청의 50%가 완료하는 데 이 시간보다 짧게 걸렸습니다.

latency_per_successful_call_(p90)

DOUBLE

성공적인 HTTP 요청의 90번째 백분위수 대기 시간입니다. 성공적인 모든 요청의 90%가 완료하는 데 이 시간보다 짧게 걸렸습니다.

latency_per_successful_call_(p95)

DOUBLE

성공적인 HTTP 요청의 95번째 백분위수 대기 시간입니다. 성공적인 모든 요청의 95%가 완료하는 데 이 시간보다 짧게 걸렸습니다.

latency_per_successful_call_(p99)

DOUBLE

성공적인 HTTP 요청의 99번째 백분위수 대기 시간입니다. 성공적인 모든 요청의 99%가 완료하는 데 이 시간보다 짧게 걸렸습니다.

input_rows

INTEGER

Number of input rows. This can be missing for an operator with no input edges from other operators.

io

쿼리 중에 수행된 I/O(입출력) 작업에 대한 정보.

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

결과 오브젝트에 기록된 바이트 수.

For example, SELECT * FROM ... would produce a set of results in tabular format representing each field in the selection.

일반적으로, 결과의 결과로 생성된 모든 것을 나타내고 bytes_written_to_result 는 반환된 결과의 크기를 나타냅니다.

bytes_read_from_result

DOUBLE

결과 오브젝트에서 읽은 바이트 수.

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

테이블 잘라내기에 대한 정보.

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

임시 결과가 메모리에 적합하지 않는 작업에 대한 디스크 사용량 정보.

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

:doc:`검색 최적화 서비스</user-guide/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

검색 최적화 및 Snowflake Optima에 의해 정리된 파티션의 수입니다.

EXECUTION_TIME_BREAKDOWN

EXECUTION_TIME_BREAKDOWN 열의 OBJECTs에 있는 필드가 아래에 나와 있습니다.

Data type

설명

overall_percentage

DOUBLE

Percentage of the total query time spent by this operator.

initialization

DOUBLE

쿼리 처리 설정에 사용한 시간.

processing

DOUBLE

CPU에서 데이터를 처리하는 데 사용한 시간.

synchronization

DOUBLE

참여 프로세스 간의 활동 동기화에 사용한 시간.

local_disk_io

DOUBLE

로컬 디스크 액세스를 기다리는 동안 처리가 차단된 시간.

remote_disk_io

DOUBLE

원격 디스크 액세스를 기다리는 동안 처리가 차단된 시간.

network_communication

DOUBLE

처리에서 네트워크 데이터 전송을 기다렸던 시간.

OPERATOR_ATTRIBUTES

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.

연산자 특성은 VARIANT 형식이고 OBJECT 를 포함하는 OPERATOR_ATTRIBUTES 열에 저장됩니다. OBJECT는 키/값 페어를 포함합니다. 각각의 키는 연산자의 한 특성에 대응됩니다.

Operator name

Data type

설명

Aggregate

functions

VARCHAR로 구성된 ARRAY

계산된 함수의 목록.

grouping_keys

VARCHAR로 구성된 ARRAY

Group-by expression.

CartesianJoin

additional_join_condition

VARCHAR

같지 않음 조인 식.

equality_join_condition

VARCHAR

같음 조인 식.

join_type

VARCHAR

조인 타입(INNER).

Delete

table_name

VARCHAR

업데이트된 테이블의 이름.

ExternalScan

stage_name

VARCHAR

데이터를 읽는 원본 스테이지의 이름.

stage_type

VARCHAR

스테이지의 유형.

Filter

filter_condition

VARCHAR

데이터를 필터링하는 데 사용되는 식.

Flatten

input

VARCHAR

Input expression used to flatten data.

Generator

row_count

NUMBER

입력 매개 변수 ROWCOUNT의 값.

time_limit

NUMBER

입력 매개 변수 TIMELIMIT의 값.

GroupingSets

functions

VARCHAR로 구성된 ARRAY

계산된 함수의 목록.

key_sets

VARCHAR로 구성된 ARRAY

그룹화 세트의 목록.

Insert

input_expression

VARCHAR

삽입되는 식.

table_names

VARCHAR로 구성된 ARRAY

레코드가 추가된 테이블 이름의 목록.

InternalObject

object_name

VARCHAR

Name of the accessed object.

Join

additional_join_condition

VARCHAR

같지 않음 조인 식.

equality_join_condition

VARCHAR

같음 조인 식.

join_type

VARCHAR

조인 타입(INNER, OUTER, LEFT JOIN 등).

JoinFilter

join_id

NUMBER

Operator id of the join used to identify tuples that can be filtered out.

Merge

table_name

VARCHAR

업데이트된 테이블의 이름.

Pivot

grouping_keys

VARCHAR로 구성된 ARRAY

결과가 집계되는 나머지 열.

pivot_column

VARCHAR로 구성된 ARRAY

피벗 값의 결과 열.

Result

expressions

VARCHAR로 구성된 ARRAY

생성된 식의 목록.

Sort

sort_keys

VARCHAR로 구성된 ARRAY

정렬 순서를 정의하는 식.

SortWithLimit

offset

NUMBER

생성된 튜플이 출력되는 순서가 지정된 시퀀스의 위치.

rows

NUMBER

생성된 행의 개수.

sort_keys

VARCHAR로 구성된 ARRAY

정렬 순서를 정의하는 식.

TableScan

columns

VARCHAR로 구성된 ARRAY

스캔된 열의 목록.

extracted_variant_paths

VARCHAR로 구성된 ARRAY

베리언트 열에서 추출된 경로의 목록.

table_alias

VARCHAR

액세스 중인 테이블의 별칭.

table_name

VARCHAR

액세스 중인 테이블의 이름.

Unload

location

VARCHAR

데이터가 저장되는 스테이지.

Unpivot

expressions

VARCHAR로 구성된 ARRAY

피벗 해제 쿼리의 출력 열.

Update

table_name

VARCHAR

업데이트된 테이블의 이름.

ValuesClause

value_count

NUMBER

생성된 값의 개수.

values

VARCHAR

값의 목록.

WindowFunction

functions

VARCHAR로 구성된 ARRAY

계산된 함수의 목록.

WithClause

name

VARCHAR

WITH 절의 별칭입니다.

연산자가 나열되지 않으면 아무런 특성도 생성되지 않고 값이 {} 으로 보고됩니다.

참고

  • The following operators do not have any operator attributes and therefore are not included in the table of OPERATOR_ATTRIBUTES:

    • UnionAll

    • ExternalFunction

다음 예제에서는 GET_QUERY_OPERATOR_STATS 함수를 호출합니다.

단일 쿼리에 대한 데이터 검색하기

이 예에서는 작은 테이블 두 개를 조인하는 SELECT의 통계를 보여줍니다.

SELECT 문을 실행합니다.

SELECT x1.i, x2.i
  FROM x1 INNER JOIN x2 ON x2.i = x1.i
  ORDER BY x1.i, x2.i;
Copy

쿼리 ID를 가져옵니다.

SET lqid = (SELECT LAST_QUERY_ID());
Copy

GET_QUERY_OPERATOR_STATS()를 호출하여 쿼리의 개별 쿼리 연산자에 대한 통계를 가져옵니다.

SELECT * FROM TABLE(GET_QUERY_OPERATOR_STATS($lqid));
Copy
+--------------------------------------+---------+-------------+--------------------+---------------+-----------------------------------------+-----------------------------------------------+----------------------------------------------------------------------+
| QUERY_ID                             | STEP_ID | OPERATOR_ID | PARENT_OPERATORS   | OPERATOR_TYPE | OPERATOR_STATISTICS                     | EXECUTION_TIME_BREAKDOWN                      | OPERATOR_ATTRIBUTES                                                  |
|--------------------------------------+---------+-------------+--------------------+---------------+-----------------------------------------+-----------------------------------------------+----------------------------------------------------------------------|
| 01a8f330-0507-3f5b-0000-43830248e09a |       1 |           0 |               NULL | Result        | {                                       | {                                             | {                                                                    |
|                                      |         |             |                    |               |   "input_rows": 64                      |   "overall_percentage": 0.000000000000000e+00 |   "expressions": [                                                   |
|                                      |         |             |                    |               | }                                       | }                                             |     "X1.I",                                                          |
|                                      |         |             |                    |               |                                         |                                               |     "X2.I"                                                           |
|                                      |         |             |                    |               |                                         |                                               |   ]                                                                  |
|                                      |         |             |                    |               |                                         |                                               | }                                                                    |
| 01a8f330-0507-3f5b-0000-43830248e09a |       1 |           1 |              [ 0 ] | Sort          | {                                       | {                                             | {                                                                    |
|                                      |         |             |                    |               |   "input_rows": 64,                     |   "overall_percentage": 0.000000000000000e+00 |   "sort_keys": [                                                     |
|                                      |         |             |                    |               |   "output_rows": 64                     | }                                             |     "X1.I ASC NULLS LAST",                                           |
|                                      |         |             |                    |               | }                                       |                                               |     "X2.I ASC NULLS LAST"                                            |
|                                      |         |             |                    |               |                                         |                                               |   ]                                                                  |
|                                      |         |             |                    |               |                                         |                                               | }                                                                    |
| 01a8f330-0507-3f5b-0000-43830248e09a |       1 |           2 |              [ 1 ] | Join          | {                                       | {                                             | {                                                                    |
|                                      |         |             |                    |               |   "input_rows": 128,                    |   "overall_percentage": 0.000000000000000e+00 |   "equality_join_condition": "(X2.I = X1.I)",                        |
|                                      |         |             |                    |               |   "output_rows": 64                     | }                                             |   "join_type": "INNER"                                               |
|                                      |         |             |                    |               | }                                       |                                               | }                                                                    |
| 01a8f330-0507-3f5b-0000-43830248e09a |       1 |           3 |              [ 2 ] | TableScan     | {                                       | {                                             | {                                                                    |
|                                      |         |             |                    |               |   "io": {                               |   "overall_percentage": 0.000000000000000e+00 |   "columns": [                                                       |
|                                      |         |             |                    |               |     "bytes_scanned": 1024,              | }                                             |     "I"                                                              |
|                                      |         |             |                    |               |     "percentage_scanned_from_cache": 1, |                                               |   ],                                                                 |
|                                      |         |             |                    |               |     "scan_progress": 1                  |                                               |   "table_name": "MY_DB.MY_SCHEMA.X2" |
|                                      |         |             |                    |               |   },                                    |                                               | }                                                                    |
|                                      |         |             |                    |               |   "output_rows": 64,                    |                                               |                                                                      |
|                                      |         |             |                    |               |   "pruning": {                          |                                               |                                                                      |
|                                      |         |             |                    |               |     "partitions_scanned": 1,            |                                               |                                                                      |
|                                      |         |             |                    |               |     "partitions_total": 1               |                                               |                                                                      |
|                                      |         |             |                    |               |   }                                     |                                               |                                                                      |
|                                      |         |             |                    |               | }                                       |                                               |                                                                      |
| 01a8f330-0507-3f5b-0000-43830248e09a |       1 |           4 |              [ 2 ] | JoinFilter    | {                                       | {                                             | {                                                                    |
|                                      |         |             |                    |               |   "input_rows": 64,                     |   "overall_percentage": 0.000000000000000e+00 |   "join_id": "2"                                                     |
|                                      |         |             |                    |               |   "output_rows": 64                     | }                                             | }                                                                    |
|                                      |         |             |                    |               | }                                       |                                               |                                                                      |
| 01a8f330-0507-3f5b-0000-43830248e09a |       1 |           5 |              [ 4 ] | TableScan     | {                                       | {                                             | {                                                                    |
|                                      |         |             |                    |               |   "io": {                               |   "overall_percentage": 0.000000000000000e+00 |   "columns": [                                                       |
|                                      |         |             |                    |               |     "bytes_scanned": 1024,              | }                                             |     "I"                                                              |
|                                      |         |             |                    |               |     "percentage_scanned_from_cache": 1, |                                               |   ],                                                                 |
|                                      |         |             |                    |               |     "scan_progress": 1                  |                                               |   "table_name": "MY_DB.MY_SCHEMA.X1" |
|                                      |         |             |                    |               |   },                                    |                                               | }                                                                    |
|                                      |         |             |                    |               |   "output_rows": 64,                    |                                               |                                                                      |
|                                      |         |             |                    |               |   "pruning": {                          |                                               |                                                                      |
|                                      |         |             |                    |               |     "partitions_scanned": 1,            |                                               |                                                                      |
|                                      |         |             |                    |               |     "partitions_total": 1               |                                               |                                                                      |
|                                      |         |             |                    |               |   }                                     |                                               |                                                                      |
|                                      |         |             |                    |               | }                                       |                                               |                                                                      |
+--------------------------------------+---------+-------------+--------------------+---------------+-----------------------------------------+-----------------------------------------------+----------------------------------------------------------------------+

“폭증하는” 조인 연산자 식별하기

다음 예에서는 GET_QUERY_OPERATOR_STATS를 사용하여 복잡한 쿼리를 검사하는 방법을 보여줍니다. 이 예에서는 그 연산자에 입력된 것보다 훨씬 더 많은 행을 생성하는 쿼리 내에서 연산자를 찾습니다.

분석할 쿼리는 다음과 같습니다.

SELECT *
  FROM t1
    JOIN t2 ON t1.a = t2.a
    JOIN t3 ON t1.b = t3.b
    JOIN t4 ON t1.c = t4.c;
Copy

이전 쿼리의 쿼리 ID를 가져옵니다.

SET lid = LAST_QUERY_ID();
Copy

The following query shows the ratio of output rows to input rows for each of the join operators in the query:

SELECT  operator_id,
        operator_attributes,
        operator_statistics:output_rows / operator_statistics:input_rows AS row_multiple
  FROM TABLE(GET_QUERY_OPERATOR_STATS($lid))
  WHERE operator_type = 'Join'
  ORDER BY step_id, operator_id;
Copy
+---------+-------------+--------------------------------------------------------------------------+---------------+
| STEP_ID | OPERATOR_ID | OPERATOR_ATTRIBUTES                                                      | ROW_MULTIPLE  |
+---------+-------------+--------------------------------------------------------------------------+---------------+
|       1 |           1 | {  "equality_join_condition": "(T4.C = T1.C)",   "join_type": "INNER"  } |  49.969249692 |
|       1 |           3 | {  "equality_join_condition": "(T3.B = T1.B)",   "join_type": "INNER"  } | 116.071428571 |
|       1 |           5 | {  "equality_join_condition": "(T2.A = T1.A)",   "join_type": "INNER"  } |  12.20657277  |
+---------+-------------+--------------------------------------------------------------------------+---------------+

폭증하는 조인을 식별한 후 각 조인 조건을 검토하여 조건이 올바른지 확인할 수 있습니다.