

 Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 Python UDF 將繼續正常運作至 2026 年 6 月 30 日。如需詳細資訊，請參閱[部落格文章](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

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

# SVCS\_PLAN\_INFO
<a name="r_SVCS_PLAN_INFO"></a>

使用 SVCS\_PLAN\_INFO 資料表，以一組資料列查看查詢的 EXPLAIN 輸出。這是查看查詢計劃的其他方法。

**注意**  
字首為 SVCS 的系統檢視可提供查詢的詳細資訊，包括主要叢集與並行擴展叢集上的查詢。這些檢視類似字首為 STL 的資料表，差別在於 STL 資料表僅提供執行於主要叢集之查詢的資訊。

所有使用者都可看見 SVCS\_PLAN\_INFO。超級使用者可以看見所有資料列；一般使用者只能看見自己的資料。如需詳細資訊，請參閱[系統資料表和檢視中資料的可見性](cm_chap_system-tables.md#c_visibility-of-data)。

## 資料表欄
<a name="r_SVCS_PLAN_INFO-table-columns"></a>


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

## 範例查詢
<a name="r_SVCS_PLAN_INFO-sample-queries"></a>

下列範例會比較藉由使用 EXPLAIN 命令，以及藉由查詢 SVCS\_PLAN\_INFO 所傳回之簡單 SELECT 查詢的查詢計劃。

```
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)
```

在此範例中，PLANNODE 104 指的是 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)
```