SVCS_PLAN_INFO - Amazon Redshift

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

SVCS_PLAN_INFO

使用 SVCS _ PLAN _ INFO 表格以一組資料列來查看查詢的EXPLAIN輸出。這是查看查詢計劃的其他方法。

注意

具有前置詞的系統檢視SVCS提供有關主要和並行縮放叢集的查詢詳細資訊。這些檢視與具有前置詞的資料表類似,不同STL之處在於STL表格僅針對在主叢集上執行的查詢提供資訊。

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

資料表欄

欄名稱 資料類型 描述
userid integer 產生項目的使用者之 ID。
query integer 查詢 ID。查詢欄可用於加入其他系統表格與檢視。
nodeid integer 計劃節點識別碼,其中節點會在查詢執行時映射至一個或多個步驟。
segment integer 識別查詢區段的號碼。
step integer 識別查詢步驟的號碼。
locus integer 執行步驟的位置。若在運算節點上則為 0,若在領導者節點上則為 1。
plannode integer 計劃節點的列舉值。請查看下表以取得 plannode 的列舉值。(中的PLANNODE欄SVCS_EXPLAIN包含計劃節點文字。)
startupcost double precision 傳回此步驟之第一列的預估相對成本。
totalcost double precision 執行步驟的預估相對成本。
rows bigint 步驟將產生之資料列的預估數目。
位元組 bigint 步驟將產生之位元組的預估數目。

範例查詢

下列範例會比較使用EXPLAIN命令並SELECT查詢 SVCS _ PLAN _ 資INFO料表所傳回之簡單查詢的查詢計劃。

explain select * from category; QUERY PLAN ------------------------------------------------------------- XN Seq Scan on category (cost=0.00..0.11 rows=11 width=49) (1 row) select * from category; catid | catgroup | catname | catdesc -------+----------+-----------+-------------------------------------------- 1 | Sports | MLB | Major League Baseball 3 | Sports | NFL | National Football League 5 | Sports | MLS | Major League Soccer ... select * from svcs_plan_info where query=256; query | nodeid | segment | step | locus | plannode | startupcost | totalcost | rows | bytes -------+--------+---------+------+-------+----------+-------------+-----------+------+------- 256 | 1 | 0 | 1 | 0 | 104 | 0 | 0.11 | 11 | 539 256 | 1 | 0 | 0 | 0 | 104 | 0 | 0.11 | 11 | 539 (2 rows)

在此範例中,PLANNODE104 指的是CATEGORY資料表的順序掃描。

select distinct eventname from event order by 1; eventname ------------------------------------------------------------------------ .38 Special 3 Doors Down 70s Soul Jam A Bronx Tale ... explain select distinct eventname from event order by 1; QUERY PLAN ------------------------------------------------------------------------------------- XN Merge (cost=1000000000136.38..1000000000137.82 rows=576 width=17) Merge Key: eventname -> XN Network (cost=1000000000136.38..1000000000137.82 rows=576 width=17) Send to leader -> XN Sort (cost=1000000000136.38..1000000000137.82 rows=576 width=17) Sort Key: eventname -> XN Unique (cost=0.00..109.98 rows=576 width=17) -> XN Seq Scan on event (cost=0.00..87.98 rows=8798 width=17) (8 rows) select * from svcs_plan_info where query=240 order by nodeid desc; query | nodeid | segment | step | locus | plannode | startupcost | totalcost | rows | bytes -------+--------+---------+------+-------+----------+------------------+------------------+------+-------- 240 | 5 | 0 | 0 | 0 | 104 | 0 | 87.98 | 8798 | 149566 240 | 5 | 0 | 1 | 0 | 104 | 0 | 87.98 | 8798 | 149566 240 | 4 | 0 | 2 | 0 | 117 | 0 | 109.975 | 576 | 9792 240 | 4 | 0 | 3 | 0 | 117 | 0 | 109.975 | 576 | 9792 240 | 4 | 1 | 0 | 0 | 117 | 0 | 109.975 | 576 | 9792 240 | 4 | 1 | 1 | 0 | 117 | 0 | 109.975 | 576 | 9792 240 | 3 | 1 | 2 | 0 | 114 | 1000000000136.38 | 1000000000137.82 | 576 | 9792 240 | 3 | 2 | 0 | 0 | 114 | 1000000000136.38 | 1000000000137.82 | 576 | 9792 240 | 2 | 2 | 1 | 0 | 123 | 1000000000136.38 | 1000000000137.82 | 576 | 9792 240 | 1 | 3 | 0 | 0 | 122 | 1000000000136.38 | 1000000000137.82 | 576 | 9792 (10 rows)