EXPLAINおよびUPDATE (Upsert形式)条件ステップ - Teradata Database - Teradata Vantage NewSQL Engine

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

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
2019年3月
Language
日本語
Last Update
2019-10-29
dita:mapPath
ja-JP/arh1512079329802.ditamap
dita:ditavalPath
ja-JP/arh1512079329802.ditaval
dita:id
B035-1142
Product Category
Software
Teradata Vantage

EXPLAIN修飾子はUPDATE (Upsert形式)処理の条件ステップの特定に役立ちます。Atomic Upsert条件ステップは、無条件更新操作が照合条件に一致しないときに実行される挿入操作です。

データベース オブジェクトDDLの例

次のDDL文は、EXPLAINの対象となるサンプルDMLリクエストによってアクセスされるテーブルを作成します。

CREATE TABLE t1 (x1 INTEGER, y1 INTEGER);
   
CREATE TABLE t2 (x2 INTEGER NOT NULL,y2 INTEGER NOT NULL);

トリガーまたは結合インデックス ステップを伴わない単純な条件付きのUpsert処理

次の例は、トリガー ステップまたは結合インデックス ステップを使用しないテーブルt1への単純な条件挿入処理を示します。

EXPLAIN 
UPDATE t1
SET y1 = 3 WHERE x1 = 2
ELSE INSERT t1(2, 3);
1) First, we do a single-AMP UPDATE from TEST.t1 by way of the
   primary index "TEST.t1.x1 = 2" with no residual conditions. If
   the row cannot be found, then we do an INSERT into TEST.t1.
...

無条件更新試行および条件挿入の両方が1つのステップに組み合わされます。

結合インデックス ステップを伴う比較的複雑なUpsert処理

次の例は、少し複雑なUpsert処理を示しています。これは、テーブルt1およびt2に結合インデックスが定義されている場合です。

結合インデックスのDDLは次のとおりです。

CREATE JOIN INDEX j AS
  SELECT *
  FROM t1 LEFT OUTER JOIN t2 ON (t1.y1 = t2.y2);

UPDATEのEXPLAIN出力の一部を次に示します。

EXPLAIN 
UPDATE t1
SET y1 = 3 WHERE x1 = 2
ELSE INSERT t1(2, 3);
...
3) We execute the following steps in parallel.
     1) We do a single-AMP DELETE from TEST.j by way of the primary
        index "TEST.j.x1 = 2" with no residual conditions.
     2) We do an all-AMPs RETRIEVE step from TEST.t2 by way of an
        all-rows scan with a condition of ("TEST.t2.y2 = 3") into
        Spool 2 (one-amp), which is redistributed by hash code to all
        AMPs. The size of Spool 2 is estimated with no confidence to
        be 1 row. The estimated time for this step is 0.02 seconds.
4) We do a single-AMP JOIN step from TEST.t1 by way of the primary
   index "TEST.t1.x1 = 2" with no residual conditions, which is
   joined to Spool 2 (Last Use). TEST.t1 and Spool 2 are left outer
   joined using a product join, with a join condition of ("(1=1)").
   The result goes into Spool 1 (one-amp), which is redistributed by
   hash code to all AMPs. Then we do a SORT to order Spool 1 by row
   hash. The size of Spool 1 is estimated with no confidence to be 3
   rows. The estimated time for this step is 0.03 seconds.
5) We execute the following steps in parallel.
     1) We do a single-AMP MERGE into TEST.j from Spool 1 (Last Use).
     2) We do a single-AMP UPDATE from TEST.t1 by way of the primary
        index "TEST.t1.x1 = 2" with no residual conditions. If the
        row cannot be found, then we do an INSERT into TEST.t1.
     3) If no update in 5.2, we do an INSERT into Spool 3.
     4) If no update in 5.2, we do an all-AMPs RETRIEVE step from
        TEST.t2 by way of an all-rows scan with no residual
        conditions into Spool 5 (all_amps), which is duplicated on
        all AMPs. The size of Spool 5 is estimated with low
        confidence to be 4 rows. The estimated time for this step is
        0.02 seconds.
6) If no update in 5.2, we do an all-AMPs JOIN step from Spool 3
   (Last Use) by way of an all-rows scan, which is joined to Spool 5
   (Last Use). Spool 3 and Spool 5 are left outer joined using a
   product join, with a join condition of ("y1 = y2"). The result
   goes into Spool 4 (one-amp), which is redistributed by hash code
   to all AMPs. Then we do a SORT to order Spool 4 by row hash. The
   size of Spool 4 is estimated with no confidence to be 2 rows. The
   estimated time for this step is 0.03 seconds.
7) If no update in 5.2, we do a single-AMP MERGE into TEST.j from
   Spool 4 (Last Use).
...

結合インデックスjによりこのEXPLAINレポートはより複雑です。ステップ5.3、5.4、6、および7で「If no update in <step number>」という句が出力されていますが、それらが更新の照合条件が一致しない場合に実行される操作を示していることに注目してください。レポートでは、MERGEが最初に更新操作の実行を試行することを示しています(ステップ5.2)。更新する行がない場合は、文により新しい行が挿入されます(ステップ5.3)。結合インデックスjは、ステップ1~4、6および7で更新されます。

単純なトリガーを伴うUpsert

次のUpsert文には単純なトリガーが含まれています。EXPLAINレポート内の該当句は太字で表示されています。

トリガーのDDLは次の通りです。

CREATE TRIGGER r1 AFTER INSERT ON t1
(UPDATE t2 SET y2 = 9 WHERE x2 = 8
 ELSE INSERT t2(8,9););

EXPLAIN出力の一部を次に示します。

EXPLAIN 
UPDATE t1
SET y1 = 3 WHERE x1 = 2
ELSE INSERT t1(2, 3);
1) First, we execute the following steps in parallel.
     1) We do a single-AMP UPDATE from TEST.t1 by way of the primary
        index "TEST.t1.x1 = 2" with no residual conditions. If the
        row cannot be found, then we do an INSERT into TEST.t1.
     2) If no update in 1.1, we do a single-AMP UPDATE from TEST.t2
        by way of the primary index "TEST.t2.x2 = 8" with no residual
        conditions. If the row cannot be found, then we do an INSERT
        into TEST.t2.
...

EXPLAINレポートは、トリガーのためにどちらかというと複雑です。ステップ1.1では、無条件更新の試行と条件挿入を処理し、ステップ1.2ではテーブルt2に対するトリガー更新を処理します。

なお、ステップ1.2の「If no update in <step number>」という句は更新のための照合条件が一致しない場合に限り実行するステップを示しています。

アボート トリガーを伴うUpsert

この例では、このDDLで定義されている条件アボート トリガーを使用します。

CREATE TRIGGER aborttrig AFTER UPDATE ON t4
(UPDATE t5 SET y5 =5 WHERE x5 = 3
 ELSE INSERT t5(3,5);
 ABORT FROM t5 WHERE x5 =1;
 DELETE t3 WHERE x3 = 10;
 ABORT 'unconditional abort';);

EXPLAINレポート内の該当句は太字で表示されています。

EXPLAIN 
UPDATE t4
SET y4 = 3 WHERE x4 = 2
ELSE INSERT t4(2, 3);
1) First, we execute the following steps in parallel.
     1) We do a single-AMP UPDATE from TEST.t4 by way of the primary
        index "TEST.t4.x4 = 2" with no residual conditions.
     2) We do a single-AMP UPDATE from TEST.t5 by way of the primary
        index "TEST.t5.x5 = 3" with no residual conditions. If the
        row cannot be found, then we do an INSERT into TEST.t5.
2) Next, we execute the following steps in parallel.
     1) If no update in 1.1, we do a single-AMP ABORT test from
        TEST.t5 by way of the primary index "TEST.t5.x5 = 1" with no
        residual conditions.
     2) If no update in 1.1, we do a single-AMP DELETE from TEST.t3
        by way of the primary index "TEST.t3.x3 = 10" with no
        residual conditions.
3) If no update in 1.1, we unconditionally ABORT the transaction.
4) If no update in 1.1, we do an INSERT into TEST.t4.
...

なお、ステップ2.1、2.2、3および4で「If no update in <step number>」という句が出力されていますが、それらは更新が成功しなかった場合に限り実行されるステップを示しています。

ステップ1.1ではt4に対して試行する無条件更新を処理します。ステップ1.2ではトリガーによって定義される更新処理を実行します。ステップ2および3は引き続きトリガー関連の操作を実行し、ステップ4ではt4の更新が失敗した場合にUpsert指定の挿入操作を実行します。

複数のトリガーを伴う複雑なUpsert

この例では、次のDDLテーブル定義リクエストによって定義される5つのテーブルを使用します。

CREATE TABLE t7 (x7 INTEGER, y7 INTEGER);

CREATE TABLE t8 (x8 INTEGER, y8 INTEGER);

CREATE TABLE t9 (x9 INTEGER, y9 INTEGER);

CREATE TABLE t10 (x10 INTEGER, y10 INTEGER);
   
CREATE TABLE t11 (x11 INTEGER, y11 INTEGER);

また、この例では、r6からr10までのトリガーに対して次の定義を使用します。

CREATE TRIGGER r6 ENABLED AFTER UPDATE ON t1
 (UPDATE t7 SET y7 = 7 WHERE x7 = 6
  ELSE INSERT t7(6, 7); );
   
CREATE TRIGGER r7 ENABLED AFTER UPDATE ON t7
 (UPDATE t8 SET y8 = 8 WHERE x8 = 7
 ELSE INSERT t8(7, 8); );
   
CREATE TRIGGER r8 ENABLED AFTER UPDATE ON t7
 (UPDATE t9 SET y9 = 8 WHERE x9 = 7
 ELSE INSERT t9(7, 8); );
   
CREATE TRIGGER r9 ENABLED AFTER INSERT ON t7
 (UPDATE t10 SET y10 = 9 WHERE x10 = 8
 ELSE INSERT t10(8, 9); );
   
CREATE TRIGGER r10 ENABLED AFTER INSERT ON t7
 (UPDATE t11 SET y11 = 10 WHERE x11 = 9
 ELSE INSERT t11(9, 10); );
   
EXPLAIN 
UPDATE t1
SET y1 = 20 WHERE x1 = 30
ELSE INSERT t1(30, 20);

EXPLAINレポート内の該当句は太字で表示されています。

1) First, we do a single-AMP UPDATE from Test.t1 by way of the 
   primary index Test.t1.x1 = 30 with no residual conditions.
2) Next, we execute the following steps in parallel.
      1) We do a single-AMP UPDATE from Test.t2 by way of the 
         primary index Test.t2.x2 = 1 with no residual conditions.
      2) If no update in 2.1, we do a single-AMP UPDATE
         from Test.t3 by way of the primary index Test.t3.x3 = 2
         with no residual conditions. If the row cannot be found, 
         then we do an INSERT into Test.t3.
3) If no update in 2.1, we do a single-AMP UPDATE from 
   Test.t4 by way of the primary index Test.t4.x4 = 3 with no 
   residual conditions. If the row cannot be found, then we do 
   an INSERT into Test.t4.
4) If no update in 2.1, we do an INSERT into Test.t2.
5) If no update in 2.1, we do a single-AMP UPDATE from 
   Test.t5 by way of the primary index Test.t5.x5 = 4 with no 
   residual conditions. If the row cannot be found, then we do 
   an INSERT into Test.t5.
6) If no update in 2.1, we do a single-AMP UPDATE from 
   Test.t6 by way of the primary index Test.t6.x6 = 5 with no 
   residual conditions. If the row cannot be found, then we do 
   an INSERT into Test.t6.
7) If no update in 2.1, we do an INSERT into Test.t1.
...

このEXPLAINレポートは、トリガーr6からr10であるため、より複雑になります。なお、ステップ2.2、3、4、5、6および7で「If no update in <step number>」という句が出力されていますが、それらは無条件の更新操作が失敗した場合に限り実行するステップを示しています。

ステップ1およびステップ7のみがAtomic Upsert文に直接関連します。ステップ2~6はトリガーr6からr10に関連します。

トリガーr6からr10を無効にする複雑なUpsert

この例では、前の例のトリガーr6からr10を無効にして、以下の新しく定義されたトリガーを呼び出します。DDLリクエストは次のとおりです。

ALTER TRIGGER r6 DISABLED;
ALTER TRIGGER r7 DISABLED;
ALTER TRIGGER r8 DISABLED;
ALTER TRIGGER r9 DISABLED;
ALTER TRIGGER r10 DISABLED;
   
CREATE TRIGGER r11 ENABLED AFTER UPDATE ON t1
(UPDATE t7 SET y7 = 7 WHERE x7 = 6
 ELSE INSERT t7(6, 7););
   
CREATE TRIGGER r12 ENABLED AFTER UPDATE ON t7
(UPDATE t8 SET y8 = 8 WHERE x8 = 7
 ELSE INSERT t8(7, 8););
   
CREATE TRIGGER r13 ENABLED AFTER UPDATE ON t7
(UPDATE t9 SET y9 = 8 WHERE x9 = 7
 ELSE INSERT t9(7, 8););
   
CREATE TRIGGER r14 ENABLED AFTER INSERT ON t7
(UPDATE t10 SET y10 = 9 WHERE x10 = 8
 ELSE INSERT t10(8, 9););
   
CREATE TRIGGER r15 ENABLED AFTER INSERT ON t7
(UPDATE t11 SET y11 = 10 WHERE x11 = 9
 ELSE INSERT t11(9, 10););
EXPLAIN 
UPDATE t1
SET y1 = 20 WHERE x1 = 30
ELSE INSERT t1(30, 20);

EXPLAINレポート内の該当句は太字で強調表示されています。

1) First, we do a single-AMP UPDATE from Test.t1 by way of
   the primary index Test.t1.x1 = 30 with no residual 
   conditions.
2) Next, we execute the following steps in parallel.
      1) We do a single-AMP UPDATE from Test.t7 by way of 
         the primary index Test.t7.x7 = 6 with no residual 
         conditions.
      2) If no update in 2.1, we do a single-AMP 
         UPDATE from Test.t8 by way of the primary index 
         Test.t8.x8 = 7 with no residual conditions. If 
         the row cannot be found, then we do an INSERT into 
         Test.t8.
3) If no update in 2.1, we do a single-AMP UPDATE from 
   Test.t9 by way of the primary    index Test.t9.x9 = 7 with 
   no residual conditions. If the row cannot be found, then
   we do an INSERT into Test.t9.
4) If no update in 2.1, we do an INSERT into Test.t7.
5) If no update in 2.1, we do a single-AMP UPDATE from 
   Test.t10 by way of the primary index Test.t10.x10 = 8 with
   no residual conditions. If the row cannot be found,then we 
   do an INSERT into Test.t10.
6) If no update in 2.1, we do a single-AMP UPDATE from 
   Test.t11 by way of the primary index Test.t11.x11 = 9 with 
   no residual conditions. If the row cannot be found,
   then we do an INSERT into Test.t11.
7) If no update in 2.1, we do an INSERT into Test.t1.
...

なお、ステップ2.2、3、4、5、6、および7で「If no update in <step number>」という句が出力されていますが、それらは更新が失敗した場合に限り実行される操作を示しています。

ステップ1およびステップ7のみがAtomic Upsert文に直接関連します。その他すべてのステップでは、トリガーr11~r15によって指定されたトリガー アクションを実行します。

トリガーr11からr15を無効にする複雑なUpsert

この例では、前の例のトリガーr11からr15を無効にして、以下の新しく定義されたトリガーを呼び出します。これらのトリガーを無効にするDDL文は次の通りです。

ALTER TRIGGER r11 DISABLED;
ALTER TRIGGER r12 DISABLED;
ALTER TRIGGER r13 DISABLED;
ALTER TRIGGER r14 DISABLED;
ALTER TRIGGER r15 DISABLED;
   
CREATE TRIGGER r16 ENABLED AFTER INSERT ON t1
(UPDATE t12 SET y12 = 11 WHERE x12 = 10
 ELSE INSERT t12(10, 11););
   
CREATE TRIGGER r17 ENABLED AFTER UPDATE ON t12
(UPDATE t13 SET y13 = 12 WHERE x13 = 11
 ELSE INSERT t13(11, 12););
   
CREATE TRIGGER r18 ENABLED AFTER UPDATE ON t12
(UPDATE t14 SET y14 = 13 WHERE x14 = 12
 ELSE INSERT t14(12, 13););
   
CREATE TRIGGER r19 ENABLED AFTER INSERT ON t12
(UPDATE t15 SET y15 = 14 WHERE x15 = 13
 ELSE INSERT t15(13, 14););
   
CREATE TRIGGER r20 ENABLED AFTER INSERT ON t12
(UPDATE t16 SET y16 = 14 WHERE x16 = 13
 ELSE INSERT t16(13, 14););

以下がEXPLAINリクエストです。

EXPLAIN 
UPDATE t1
SET y1 = 20 WHERE x1 = 30
ELSE INSERT t1(30, 20);

EXPLAINレポート内の該当句は太字で表示されています。

1) First, we execute the following steps in parallel.
   1) We do a single-AMP UPDATE from Test.t1 by way of the primary
      index Test.t1.x1 = 30 with no residual conditions.
      If the row cannot be found, then we do an INSERT into
      Test.t1.
   2) If no update in 1.1, we do a single-AMP UPDATE from Test.t12 
      by way of the primary index Test.t12.x12 = 10 with no residual 
      conditions.
   3) If no update in 1.2, we do a single-AMP UPDATE from Test.t13 
      by way of the primary index Test.t13.x13 = 11 with no residual 
      conditions. If the row cannot be found, then we do an INSERT
      into Test.t13.
2) Next, if no update in 1.2, we do a single-AMP UPDATE from 
   Test.t14 by way of the primary index Test.t14.x14 = 12 with no 
   residual conditions. If the row cannot be found, then we do an
   INSERT into Test.t14.
3) If no update in 1.2, we do an INSERT into Test.t12.
4) If no update in 1.2, we do a single-AMP UPDATE from Test.t15 by way
   of the primary index Test.t15.x15 = 13 with no residual conditions.
   If the row cannot be found,then we do an INSERT into Test.t15.
5) If no update in 1.2, we do a single-AMP UPDATE from Test.t16 by way 
   of the primary index Test.t16.x16 = 13 with no residual conditions. 
   If the row cannot be found,then we do an INSERT into Test.t16.
...

なお、ステップ1.2、1.3、2、3、4、および5で「If no update in <step number>」という句が出力されていますが、それらは更新が失敗した場合に限り実行される操作を示しています。

ステップ1.1のみがAtomic Upsert文に直接関連します。その他すべてのステップでは、トリガーr16~r20によって指定されたトリガー アクションを実行します。

上記の例とは異なるトリガーを伴う複雑なUpsert

この例では、前の例のトリガーr16からr20を無効にして、以下の新しく定義されたトリガーを呼び出します。この例のクエリー計画は、前の計画と同じで、EXPLAINレポートの最後で確認します。

ALTER TRIGGER r16 DISABLED;
ALTER TRIGGER r17 DISABLED;
ALTER TRIGGER r18 DISABLED;
ALTER TRIGGER r19 DISABLED;
ALTER TRIGGER r20 DISABLED;
   
CREATE TRIGGER r21 ENABLED AFTER INSERT ON t1
(UPDATE t17 SET y17 = 11 WHERE x17 = 10
 ELSE INSERT t17(10, 11););
   
CREATE TRIGGER r22 ENABLED AFTER UPDATE ON t17
(UPDATE t18 SET y18 = 12 WHERE x18 = 11
 ELSE INSERT t18(11, 12););
   
CREATE TRIGGER r23 ENABLED AFTER UPDATE ON t17
(UPDATE t19 SET y19 = 13 WHERE x19 = 12
 ELSE INSERT t19(12, 13););
   
CREATE TRIGGER r24 ENABLED AFTER INSERT ON t17
(UPDATE t20 SET y20 = 14 WHERE x20 = 13
 ELSE INSERT t20(13, 14););
   
CREATE TRIGGER r25 ENABLED AFTER INSERT ON t17
(UPDATE t21 SET y21 = 14 WHERE x21 = 13
 ELSE INSERT t21(13, 14););
   
EXPLAIN 
UPDATE t1
SET y1 = 20 WHERE x1 = 30
ELSE INSERT t1(30, 20);

EXPLAINレポート内の該当句は太字で表示されています。

1) First, we execute the following steps in parallel.
      1) We do a single-AMP UPDATE from Test.t1 by way of the primary
         index Test.t1.x1 = 30 with no residual conditions. If the row 
         cannot be found, then we do an INSERT into Test.t1.
      2) If no update in 1.1, we do a single-AMP UPDATE from 
         Test.t17 by way of the primary index Test.t17.x17 = 10 with 
         no residual conditions.
      3) If no update in 1.2, we do a single-AMP UPDATE from 
         Test.t18 by way of the primary index Test.t18.x18 = 11 with 
         no residual conditions. If the row cannot be found, then we 
         do an INSERT into Test.t18.
2) Next, if no update in 1.2, we do a single-AMP UPDATE from 
   Test.t19 by way of the primary index Test.t19.x19 = 12 with no 
   residual conditions. If the row cannot be found, then we do an 
   INSERT into Test.t19.
3) If no update in 1.2, we do an INSERT into Test.t17.
4) If no update in 1.2, we do a single-AMP UPDATE from Test.t20 
   by way of the primary index Test.t20.x20 = 13 with no residual 
   conditions. If the row cannot be found, then we do an INSERT into 
   Test.t20.
5) If no update in 1.2, we do a single-AMP UPDATE from Test.t21 
   by way of the primary index Test.t21.x21 = 13 with no residual 
   conditions. If the row cannot be found, then we do an INSERT into 
   Test.t21.
...

なお、ステップ1.2、1.3、2、3、4、および5で「If no update in <step number>」という句が出力されていますが、それらは更新が失敗した場合に限り実行される操作を示しています。

ステップ1.1のみがAtomic Upsert文に直接関連します。その他すべてのステップでは、トリガーr21~r25によって指定されたトリガー アクションを実行します。

上記の例からの複数のトリガーを伴う複雑なUpsert

この例は、有効なトリガーr1~r15により、多くのステップを追加する一連の条件を実行します。前の例では、トリガーr21~r25がすでに有効になっています。

ALTER TRIGGER r1 ENABLED;
ALTER TRIGGER r2 ENABLED;
ALTER TRIGGER r3 ENABLED;
ALTER TRIGGER r4 ENABLED;
ALTER TRIGGER r5 ENABLED;
ALTER TRIGGER r6 ENABLED;
ALTER TRIGGER r7 ENABLED;
ALTER TRIGGER r8 ENABLED;
ALTER TRIGGER r9 ENABLED;
ALTER TRIGGER r10 ENABLED;
ALTER TRIGGER r11 ENABLED;
ALTER TRIGGER r12 ENABLED;
ALTER TRIGGER r13 ENABLED;
ALTER TRIGGER r14 ENABLED;
ALTER TRIGGER r15 ENABLED;
   
EXPLAIN 
UPDATE t1
SET y1 = 20 WHERE x1 = 30
ELSE INSERT t1(30, 20);

EXPLAINレポート内の該当句は太字で表示されています。

1) First, we do a single-AMP UPDATE from Test.t1 by way of the primary
   index Test.t1.x1 = 30 with no residual conditions.
2) Next, we execute the following steps in parallel.
      1) We do a single-AMP UPDATE from Test.t2 by way of the primary 
         index Test.t2.x2 = 1 with no residual conditions.
      2) If no update in 2.1, we do a single-AMP UPDATE from 
         Test.t3 by way of the primary index Test.t3.x3 = 2 with no 
         residual conditions. If the row cannot be found, then we do 
         an INSERT into Test.t3.
3) If no update in 2.1, we do a single-AMP UPDATE from Test.t4 
   by way of the primary index Test.t4.x4 = 3 with no residual 
   conditions. If the row cannot be found, then we do an INSERT into 
   Test.t4.
4) If no update in 2.1, we do an INSERT into Test.t2.
5) If no update in 2.1, we do a single-AMP UPDATE from Test.t5 
   by way of the primary index Test.t5.x5 = 4 with no residual
   conditions. If the row cannot be found, then we do an INSERT
   into Test.t5.
6) If no update in 2.1, we do a single-AMP UPDATE from Test.t6 by 
   way of the primary index Test.t6.x6 = 5 with no residual conditions. 
   If the row cannot be found, then we do an INSERT into Test.t6.
7) We execute the following steps in parallel.
      1) We do a single-AMP UPDATE from Test.t7 by way of the primary
         index Test.t7.x7 = 6 with no residual conditions.
      2) If no update in 7.1, we do a single-AMP UPDATE from 
         Test.t8 by way of the primary index Test.t8.x8 = 7 with no 
         residual conditions. If the row cannot be found, then we do 
         an INSERT into Test.t8.
8) If no update in 7.1, we do a single-AMP UPDATE from Test.t9 
   by way of the primary    index Test.t9.x9 = 7 with no residual 
   conditions. If the row cannot be found, then we do an INSERT into 
   Test.t9.
9) If no update in 7.1, we do an INSERT into Test.t7.
10)If no update in 7.1, we do a single-AMP UPDATE from Test.t10 
   by way of the primary index Test.t10.x10 = 8 with no residual 
   conditions. If the row cannot be found,then we do an INSERT into 
   Test.t10.
11)If no update in 7.1, we do a single-AMP UPDATE from Test.t11 
   by way of the primary index Test.t11.x11 = 9 with no residual 
   conditions. If the row cannot be found, then we do an INSERT into 
   Test.t11.
12) If no update in 7.1, we do an INSERT into Test.t1.
13) We execute the following steps in parallel.
      1) If no update in 1, we do a single-AMP UPDATE from 
         Test.t12 by way of the primary index Test.t12.x12 = 10 
         with no residual conditions.
      2) If no update in 13.1, we do a single-AMP UPDATE 
         from Test.t13 by way of the primary index Test.t13.x13 = 11 
         with no residual conditions. If the row cannot be found, 
         then we do an INSERT into Test.t13.
14) If no update in 13.1, we do a single-AMP UPDATE from Test.t14 
    by way of the primary index Test.t14.x14 = 12 with no residual 
    conditions. If the row cannot be found,then we do an INSERT into 
    Test.t14.
15) If no update in 13.1, we do an INSERT into Test.t12.
16) If no update in 13.1, we do a single-AMP UPDATE from Test.t15 
    by way of the primary index Test.t15.x15 = 13 with no residual 
    conditions. If the row cannot be found,then we do an INSERT into
    Test.t15.
17) If no update in 13.1, we do a single-AMP UPDATE from Test.t16 
    by way of the primary index Test.t16.x16 = 13 with no residual 
    conditions. If the row cannot be found,then we do an INSERT into
    Test.t16.
18) We execute the following steps in parallel.
      1) If no update in 1, we do a single-AMP UPDATE from Test.t17 
         by way of the primary index Test.t17.x17 = 10 with no
         residual conditions.
      2) If no update in 18.1, we do a single-AMP UPDATE from 
         Test.t18 by way of the primary index Test.t18.x18 = 11 
         with no residual conditions. If the row cannot be found,
         then we do an INSERT into Test.t18.
19) If no update in 18.1, we do a single-AMP UPDATE from Test.t19 
    by way of the primary index Test.t19.x19 = 12 with no residual 
    conditions. If the row cannot be found, then we do an INSERT into 
    Test.t19.
20) If no update in 18.1, we do an INSERT into Test.t17.
21) If no update in 18.1, we do a single-AMP UPDATE from Test.t20 
    by way of the primary index Test.t20.x20 = 13 with no residual 
    conditions. If the row cannot be found, then we do an INSERT into 
    Test.t20.
22) If no update in 18.1, we do a single-AMP UPDATE from Test.t21 
    by way of the primary index Test.t21.x21 = 13 with no residual 
    conditions. If the row cannot be found, then we do an INSERT into 
    Test.t21.
...

なお、ステップ2.2、3、4、5、6、7.2、8、9、10、11、12、13.1、13.2、14、15、16、17、18.1、18.2、19、20、21、および22で「If no update in <step number>」という句が出力されていますが、それらは更新が失敗した場合に限り実行される操作を示しています。

ステップ1およびステップ12のみがAtomic Upsert文に直接関連します。その他すべてのステップでは、トリガーによって指定されているトリガー アクションを実行します。

また、ステップ13.1および18.1はステップ1のアクションに基づいていることに注目してください。これはトリガーr16およびr21が対象となるテーブルt1についての挿入トリガー文によって定義されているためです。

これらの例でのEXPLAINリクエスト修飾子の用語

EXPLAINレポートのこのセットの新しい用語は、次のように定義されます。

定義
if no update in <step number> 更新段階の照合条件が一致しない場合、条件付き挿入段階が実行されます。

<step number>はMERGE更新ステップを示します。

if <step number> not executed, UPDATEブロックの最初のステップが実行されない場合に実行されるアクションを示します。

<step number>が1より大きい場合に限りレポートされます。