SYS_QUERY_DETAIL
SYS_QUERY_DETAIL により、ステップレベルでクエリの詳細を表示できます。各行が特定の WLM クエリのステップを表し、詳細情報が含まれます、このビューには、DDL、DML、ユーティリティコマンド (コピーおよびアンロード) など、多くの種類のクエリが含まれています。クエリの種類によっては、一部の列との関連がない場合があります。例えば、external_scanned_bytes は内部テーブルには関係しません。
SYS_QUERY_DETAIL はすべてのユーザーが表示可能です。スーパーユーザーはすべての行を表示できますが、通常のユーザーは自分のデータのみを表示できます。詳細については、「システムテーブルとビューのデータの可視性」を参照してください。
テーブルの列
列名 | データ型 | 説明 |
---|---|---|
user_id | integer | クエリを送信したユーザーの ID。 |
query_id | bigint | クエリ識別子。 |
child_query_sequence | integer | 書き換えられたユーザークエリのシーケンス。 |
stream_id | integer | クエリストリームのストリーム識別子。 |
segment_id | integer | クエリ実行セグメントのセグメント識別子。 |
step_id | integer | セグメント内のステップ識別子。 |
step_name | text | セグメント内のステップ名。指定できる値は、aggregate 、broadcast 、delete 、distribute 、hash 、hashjoin 、insert 、limit 、merge 、nestloop 、parse 、return 、save 、scan 、sort 、sortlimit 、unique 、window です。 |
table_id | integer | 永続テーブルスキャン時のテーブル識別子。 |
table_name | character(136) | 実行中のステップでのテーブル名。 |
is_rrscan | 文字 | ステップがスキャンステップであるかどうかを示す値。true (t) の場合は、そのステップで範囲が限定されたスキャンが実行されたことを示します。 |
start_time | timestamp | クエリステップが開始された時刻。 |
end_time | timestamp | クエリステップが完了した時刻。 |
duration | bigint | そのステップに消費された時間 (マイクロ秒)。 |
アラート | text | アラートイベントの説明。 |
input_bytes | bigint | 現在のステップの入力バイト数。 |
input_rows | bigint | 現在のステップの入力行数。 |
output_bytes | bigint | 現在のステップの出力バイト数。 |
output_rows | bigint | 現在のステップの出力行数。 |
blocks_read | bigint | ステップが読み込んだブロックの数。 |
blocks_write | bigint | ステップが書き込んだブロックの数。 |
local_read_IO | bigint | ローカルディスクキャッシュから読み取られるブロック数。 |
remote_read_IO | bigint | リモートから読み込んだブロックの数。 |
ソース | text | スキャンされたデータベースオブジェクトの型。この列が値を持つのは、行の step_name 値が scan である場合のみです。 |
data_skewness | integer | すべてのステップ間における出力行の分布の歪み。0% から 100% までの範囲の数値です。数値が大きいほど、分布のバランスに歪みがあります。 |
time_skewness | integer | すべてのステップ間における実行時間分布の歪み。0% から 100% までの範囲の数値です。数値が大きいほど、分布のバランスに歪みがあります。 |
is_active | 文字 | ステップレベルでのクエリの状態。可能な値は、ステップがアクティブに実行中であることを示す「t」、ステップの実行が完了したことを示す「f」です。 |
spilled_block_local_disk | bigint | ローカルディスクに流出したブロックの数。 |
spilled_block_remote_disk | bigint | Amazon Simple Storage Service に流出したブロックの数。 |
step_attribute | character(64) | 関連のステップに関する情報が含まれます。スキャンステップに指定できる値: multi-dimensional 。 |
サンプルクエリ
次の例では、SYS_QUERY_DETAIL の出力を返します。
次のクエリは、ステップ名、input_bytes、output_bytes、input_rows、output_rows を含め、ステップレベルでクエリメタデータの詳細を表示します。
SELECT query_id, child_query_sequence, stream_id, segment_id, step_id, trim(step_name) AS step_name, duration, input_bytes, output_bytes, input_rows, output_rows FROM sys_query_detail WHERE query_id IN (193929) ORDER BY query_id, stream_id, segment_id, step_id DESC;
サンプル出力。
query_id | child_query_sequence | stream_id | segment_id | step_id | step_name | duration | input_bytes | output_bytes | input_rows | output_rows ----------+----------------------+-----------+------------+---------+------------+-----------------+-------------+--------------+------------+------------- 193929 | 2 | 0 | 0 | 3 | hash | 37144 | 0 | 9350272 | 0 | 292196 193929 | 5 | 0 | 0 | 3 | hash | 9492 | 0 | 23360 | 0 | 1460 193929 | 1 | 0 | 0 | 3 | hash | 46809 | 0 | 9350272 | 0 | 292196 193929 | 4 | 0 | 0 | 2 | return | 7685 | 0 | 896 | 0 | 112 193929 | 1 | 0 | 0 | 2 | project | 46809 | 0 | 0 | 0 | 292196 193929 | 2 | 0 | 0 | 2 | project | 37144 | 0 | 0 | 0 | 292196 193929 | 5 | 0 | 0 | 2 | project | 9492 | 0 | 0 | 0 | 1460 193929 | 3 | 0 | 0 | 2 | return | 11033 | 0 | 14336 | 0 | 112 193929 | 2 | 0 | 0 | 1 | project | 37144 | 0 | 0 | 0 | 292196 193929 | 1 | 0 | 0 | 1 | project | 46809 | 0 | 0 | 0 | 292196 193929 | 5 | 0 | 0 | 1 | project | 9492 | 0 | 0 | 0 | 1460 193929 | 3 | 0 | 0 | 1 | aggregate | 11033 | 0 | 201488 | 0 | 14 193929 | 4 | 0 | 0 | 1 | aggregate | 7685 | 0 | 28784 | 0 | 14 193929 | 5 | 0 | 0 | 0 | scan | 9492 | 0 | 23360 | 292196 | 1460 193929 | 4 | 0 | 0 | 0 | scan | 7685 | 0 | 1344 | 112 | 112 193929 | 2 | 0 | 0 | 0 | scan | 37144 | 0 | 7304900 | 292196 | 292196 193929 | 3 | 0 | 0 | 0 | scan | 11033 | 0 | 13440 | 112 | 112 193929 | 1 | 0 | 0 | 0 | scan | 46809 | 0 | 7304900 | 292196 | 292196 193929 | 5 | 0 | 0 | -1 | | 9492 | 12288 | 0 | 0 | 0 193929 | 1 | 0 | 0 | -1 | | 46809 | 16384 | 0 | 0 | 0 193929 | 2 | 0 | 0 | -1 | | 37144 | 16384 | 0 | 0 | 0 193929 | 4 | 0 | 0 | -1 | | 7685 | 28672 | 0 | 0 | 0 193929 | 3 | 0 | 0 | -1 | | 11033 | 114688 | 0 | 0 | 0
データベース内のテーブルを、使用頻度の高い順に表示するには、次の例を使用します。sample_data_dev
を独自のデータベースに置き換えます。このクエリはクラスターの作成時に開始されるクエリをカウントしますが、データウェアハウスのスペースが不足している場合はシステムビューデータが保存されないことに注意してください。
SELECT table_name, COUNT (DISTINCT query_id) FROM SYS_QUERY_DETAIL WHERE table_name LIKE 'sample_data_dev%' GROUP BY table_name ORDER BY COUNT(*) DESC;
+---------------------------------+-------+ | table_name | count | +---------------------------------+-------+ | sample_data_dev.tickit.venue | 4 | | sample_data_dev.myunload1.venue | 3 | | sample_data_dev.tickit.listing | 1 | | sample_data_dev.tickit.category | 1 | | sample_data_dev.tickit.users | 1 | | sample_data_dev.tickit.date | 1 | | sample_data_dev.tickit.sales | 1 | | sample_data_dev.tickit.event | 1 | +---------------------------------+-------+