SYS_QUERY_DETAIL - Amazon Redshift

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

SYS_QUERY_DETAIL

使用 SYS _ QUERY _ DETAIL 來檢視步驟層級查詢的詳細資訊。每一列代表來自具有詳細資訊之特定WLM查詢的一個步驟。此檢視包含許多類型的查詢,例如DDLDML、和公用程式指令 (例如,複製和卸載)。根據查詢類型的不同,某些欄可能不相關。例如,external_scanned_bytes 與內部資料表不相關。

SYS_ QUERY _ DETAIL 對所有用戶都可以看到。超級使用者可以看見所有資料列;一般使用者只能看見自己的資料。如需詳細資訊,請參閱系統資料表和檢視中資料的可見性

資料表欄

欄名稱 資料類型 描述
user_id integer 提交查詢之使用者的識別碼。
query_id bigint 查詢識別碼。
child_query_sequence integer 重寫使用者查詢的順序,從 1 開始。
stream_id integer 查詢串流的資料流識別碼。
segment_id integer 查詢執行區段的區段識別碼。
step_id integer 區段中的步驟識別碼。
step_name text 區段中的步驟名稱。可能的值為aggregatebroadcastdeletedistributehashhashjoininsertlimitmergenestloopparsereturnsave、、scansortsortlimitunique、和window
table_id integer 永久資料表掃描的資料表識別碼。
table_name character(136) 正在操作之步驟的資料表名稱。
is_rrscan character 指示步驟是否為掃描步驟的值。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 從遠端讀取的區塊數。
source text 已掃描的資料庫物件類型。只有當列的 step_name 值為 scan 時,此欄才有值。
data_skewness integer 輸出列在所有步驟之間分佈的偏態。它是一個在 0% 到 100% 的範圍內的數字。數字越大,分佈越不平衡。
time_skewness integer 所有步驟之間執行時間分佈的偏態。它是一個在 0% 到 100% 的範圍內的數字。數字越大,分佈越不平衡。
is_active character 步驟層級查詢的狀態。可能的值是 ‘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

若要檢視資料庫中的資料表,從最常用到最少使用的順序,請使用下列範例。Replace (取代) 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 | +---------------------------------+-------+