EXPLAINリクエスト修飾子とトリガー - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQLリクエストおよびトランザクション処理

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
2020年6月
Language
日本語
Last Update
2021-03-30
dita:mapPath
ja-JP/ykx1561500561173.ditamap
dita:ditavalPath
ja-JP/ykx1561500561173.ditaval
dita:id
B035-1142
Product Category
Software
Teradata Vantage

ループ トリガー アクションを使用する行トリガーの例

この例では、t1、t2、およびt3の3つのテーブルおよびt1を使用するAFTER行トリガーが対象となるテーブルとして作成されます。トリガー アクションはテーブルt2およびt3を修正します。

INSERT操作のEXPLAINテキストは、トリガー アクションの一部ですが、行トリガー ループの開始と終了を特にマークします。EXPLAINレポート内の該当句は太字で強調表示されています。

テーブルおよびトリガーを作成するDDL文は次のとおりです。

CREATE TABLE t1(
 i INTEGER,
 j INTEGER);

CREATE TABLE t2(
 i INTEGER,
 j INTEGER);

CREATE TABLE t3(
 i INTEGER,
 j INTEGER);

CREATE TRIGGER g1 AFTER INSERT ON t1
FOR EACH ROW (
 UPDATE t2 SET j = j+1;
 DELETE t2;
 DELETE t3;);

EXPLAINテキストでは以下のINSERT … SELECT文を処理するために使用するステップをレポートします。

EXPLAIN 
INSERT t1 SELECT * FROM t3;

1) First, we lock mws.t3 in TD_MAP1 for write on a reserved RowHash
   to prevent global deadlock.
2) Next, we lock mws.t2 in TD_MAP1 for write on a reserved RowHash
   to prevent global deadlock.
3) We lock mws.t1 in TD_MAP1 for write on a reserved RowHash to
   prevent global deadlock.
4) We lock mws.t3 in TD_MAP1 for write, we lock mws.t2 in TD_MAP1
   for write, and we lock mws.t1 in TD_MAP1 for write.
5) We do an all-AMPs MERGE step in TD_MAP1 into mws.t1 from mws.t3
   followed by an insert in Spool 1.  The size is estimated with low
   confidence to be 8 rows.  The estimated time for this step is 3.94
   seconds.
6) <BEGIN ROW TRIGGER LOOP>
   we do an all-AMPs UPDATE step in TD_MAP1 from mws.t2 by way of an
   all-rows scan with no residual conditions.  The size is estimated
   with low confidence to be 8 rows.  The estimated time for this
   step is 0.09 seconds.
7) We do an all-AMPs DELETE step in TD_MAP1 from mws.t2 by way of an
   all-rows scan with no residual conditions.  The size is estimated
   with low confidence to be 8 rows.  The estimated time for this
   step is 2.44 seconds.
8) We do an all-AMPs DELETE step in TD_MAP1 from mws.t3 by way of an
   all-rows scan with no residual conditions.  The size is estimated
   with low confidence to be 8 rows.  The estimated time for this
   step is 2.44 seconds.
   <END ROW TRIGGER LOOP> for step 6.
9) We spoil the parser's dictionary cache for the table.
10) We spoil the parser's dictionary cache for the table.
11) We spoil the parser's dictionary cache for the table.
...