結合DELETE操作の実行時に結合インデックスを保守するための一般的な方法 - 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

ここでは、Teradata Databaseが基本テーブルに対して結合削除操作を実行するときに、結合インデックスを保守する一般的な方法について説明します。

結合DELETE操作の結合インデックスの保守について

結合削除は、以下に示す結合インデックスが定義されている基本テーブルからの削除の一般的な例のように、いくつかの結合条件を使用してFROM句で複数のテーブルを指定するときに基本テーブルに対して実行されます。

     DELETE delete_table_name
     FROM join_table_name_1, join_table_name_n
     WHERE condition;

プライマリ インデックス付けされた結合インデックスによりプライマリ インデックス付けされたテーブルからの結合削除

結合削除は、適格な行のスプールを使用するテーブルからの削除で行なわれます。Teradata Databaseは以下の結合削除計画を、プライマリ インデックス付きの結合インデックスによりプライマリ インデックス付きの基本テーブルに対して使用します。

  6) We do an all-AMPs JOIN step (No Sum) from Spool 2 (Last Use) 
     by way of a RowHash match scan, which is joined to Spool 3 
     (Last Use) by way of a RowHash match scan. Spool 2 and Spool 3 
     are joined using a merge join, with a join condition of 
     ("Spool_3.col2 = Spool_2.y1"). The result goes into Spool 1 
     (all_amps), which is redistributed by hash code to all AMPs with 
     hash fields ("Spool_3.Field_1025"). Then we do a SORT to order 
     Spool 1 by row hash. The size of Spool 1 is estimated with no 
     confidence to be 2 rows (50 bytes). Spool Asgnlist:
     "Field_1025" = "Spool_3.Field_1025",
     "Field_1026" = "{RightTable}.Field_1026",
     "Field_1027" = "{RightTable}.Field_1027".
     The estimated time for this step is 0.03 seconds.
  7) We do an all-AMPs MERGE DELETE to DRCP_DELETE.t_pi from Spool 1.
     The size is estimated with no confidence to be 2 rows. The
     estimated time for this step is 0.76 seconds.
  8) We do an all-AMPs RETRIEVE step from Spool 1 (Last Use) by way of
     an all-rows scan into Spool 4 (all_amps), which is redistributed
     by hash code to all AMPs with hash fields ("Spool_1.col3").
     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 (42 bytes). Spool
     Asgnlist: "col2",
     "Spool_1.col3".
  9) We do an all-AMPs MERGE DELETE to drcp_delete.NONCPJI from Spool 4
     (Last Use). The size is estimated with no confidence to be 2 rows.
     The estimated time for this step is 0.74 seconds.	

プライマリ インデックス付きの結合インデックスにより列パーティション化されたNoPI テーブルからの結合削除

プライマリ インデックス付きの結合インデックスにより列パーティション化されたNoPI基本テーブルの場合、前述の例のステップ6に示されているように、列パーティション化されたテーブルからすべての列を取り出すことは、非常にコストが高くなります。そのため、このケースでは列パーティション化されたテーブルの行IDのみがスプールされ、そのスプールが列パーティション化されたテーブルに対するマージ削除操作に使用されます。

Teradata Databaseは、この行IDスプールと列パーティション化されたテーブルを結合して、プライマリ インデックス付きの結合インデックスに対してマージ削除操作を行なうために使用される、適格な結合インデックス行を提供します(以下のEXPLAINテキストのステップ8に示すように)。

  6) We do an all-AMPs JOIN step (No Sum) from Spool 2 (Last Use) by
     way of a RowHash match scan, which is joined to Spool 3 (Last Use)
     by way of a RowHash match scan. Spool 2 and Spool 3 are joined
     using a merge join, with a join condition of ("Spool_3.cpcol2 =
     Spool_2.y1"). The result goes into Spool 1 (all_amps), which is
     redistributed by hash code to all AMPs with hash fields (
     "Spool_3.Field_1"). Then we do a SORT to order Spool 1 by row
     hash. The size of Spool 1 is estimated with no confidence to be 2
     rows (50 bytes). Spool Asgnlist:
     "Field_1" = "Spool_3.Field_1"
     The estimated time for this step is 0.03 seconds.
  7) We do an all-AMPs JOIN step (No Sum) from Spool 1 (Last Use), 
     which is joined DRCP_DELETE.cpt. Spool 1 and DRCP_DELETE.cpt 
     are joined using a rowid join, with a join condition of 
    ("Spool_1.Field_1 = cpt.ROWID"). The result goes into Spool X 
    (all_amps), which is redistributed by hash code to all AMPs with 
     hash fields ("Spool_X.cpcol3"). Then we do a SORT to order 
     Spool X by row hash. The size of Spool 1 is estimated with 
     no confidence to be 2 rows (50 bytes). Spool Asgnlist:
     "Spool_x.col2",
     "Spool_X.col3".
     The estimated time for this step is 0.03 seconds.
  8)  We do an all-AMPs MERGE DELETE to DRCP_DELETE.cpt from Spool 1 via the rowid。  The size is estimated with no confidence to be 2 rows. 
     The estimated time for this step is 0.76 seconds.
  9) We do an all-AMPs MERGE DELETE to drcp_delete.NONCPJI from Spool X
     (Last Use). The size is estimated with no confidence to be 2 rows.
     The estimated time for this step is 0.74 seconds.	

列パーティション化されたNoPI結合インデックスにより列パーティション化されたテーブルからの結合削除

適格行のスプールを使用してテーブルから削除が行なわれるときに、結合削除が行なわれます。この例の場合、Teradata Databaseは、ステップ7(太字)で示すように、適格な行を削除するために、基本テーブルの行自体ではなく行IDの値を適格な行のスプール(Spool 4)に追加することだけが必要になります。同じ結合インデックススプールは、以下のEXPLAINテキストが示すように、列パーティション化された結合インデックスに対するマージ削除操作を実行するために使用されます。

  6) We do an all-AMPs JOIN step (No Sum) from Spool 2 (Last Use) by
     way of a RowHash match scan, which is joined to Spool 3 (Last Use)
     by way of a RowHash match scan. Spool 2 and Spool 3 are joined
     using a merge join, with a join condition of ("Spool_3.cpcol2 =
     Spool_2.y1"). The result goes into Spool 1 (all_amps), which is
     redistributed by hash code to all AMPs with hash fields (
     "Spool_3.Field_1") and Field1 ("Spool_3.Field_1"). Then we do a
     SORT to order Spool 1 by row hash and the sort key in spool field1
     eliminating duplicate rows. The size of Spool 1 is estimated with
     no confidence to be 4 rows (72 bytes). Spool Asgnlist:
     "Field_1" = "Spool_3.Field_1".
     The estimated time for this step is 0.13 seconds.
  7) We do an all-AMPs MERGE DELETE to DRCP_DELETE.cpt from Spool 1
     (Last Use) via the row id.  Also, deleted rows are inserted in 
      Spool 4. The size is estimated with no confidence to be 4 rows.
     The estimated time for this step is 15.04 seconds.
  8) We do an all-AMPs RETRIEVE step from Spool 4 (Last Use) by way of
     an all-rows scan into Spool 5 (all_amps), which is redistributed
     by hash code to all AMPs with hash fields ("Spool_4.ROWID").
     Then we do a SORT to order Spool 5 by row hash. The size of Spool
     5 is estimated with no confidence to be 4 rows (84 bytes). Spool
     Asgnlist: "Spool_4.ROWID"
     The estimated time for this step is 0.10 seconds.
  9) We do an all-AMPs MERGE DELETE to drcp_delete.CPJ1 from Spool 5
     (Last Use) using FTS_RowIDMatch. The size is estimated with no
     confidence to be 4 rows.
     The estimated time for this step is 10.53 seconds.