STATIC 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

静的問合わせ計画について

増分計画および実行(IPE)によって生成されたのではない問合わせ計画は、静的問合わせ計画と呼ばれます。静的問合わせ計画は、説明されたリクエストに対して従来返される問合わせ計画です。

最適化ルーチンは、IPEに適格なリクエストに関して静的クエリー計画を生成することがあります。以下の状況では、説明されているリクエストがIPEに適格な場合に静的クエリー計画が生成される可能性があります。
  • リクエストがIPEに適格なものの、システム制御の特定のしきい値基準を満たしていない場合。

    この場合、Teradata Databaseはレポートされたステップの前に以下の句を配置します。「This request is eligible for incremental planning and execution (IPE) but doesn't meet thresholds. The following is the static plan for the request.」

  • リクエストがIPEに適格で、実行されると、最適化ルーチンによりレポートされた静的計画ではなく動的計画が生成される可能性があるが、Teradata Databaseが静的計画または静的計画からの要約情報を使用して、ワークロードのフィルタ、スロットル、および分類基準を評価する場合。

    この場合、Teradata Databaseはレポートされたステップの前に以下の句を配置します。「This request is eligible for incremental planning and execution (IPE). The following is the static plan for the request.」

  • リクエストがIPEに適格なものの、サイトでIPEが無効な場合。
    この場合、Teradata Databaseは、次の句を使用して静的クエリー計画を報告します。
    This request is eligible for incremental planning and execution (IPE). IPE is disabled. The following is the static plan for the request.

静的EXPLAINレポートのリクエスト

リクエストの静的EXPLAINレポートを依頼する場合、キーワードEXPLAINに先行してキーワードSTATICを指定します。

EXPLAINリクエスト修飾子のデフォルト設定はSTATICであるため、EXPLAINの前にキーワードSTATICを配置するかどうかにかかわらず、ほとんどのサイトでは静的EXPLAINレポートが生成されます。

EXPLAINキーワードの後にIN XMLキーワードを指定すると、レポートをXML形式で返すように要求できます。

EXPLAINリクエスト修飾子について詳しくは、<Teradata Vantage™ - SQLデータ操作言語、B035-1146>の「EXPLAINリクエスト修飾子」を参照してください。

リクエストが増分計画および実行に適格な場合のSTATIC EXPLAINレポート

この例では、システムが動的計画をレポートしないように設定されているとします。この場合、Teradata Databaseは、リクエストがIPEに適格であることを示す静的計画をレポートします。その際、STATICキーワードが暗黙的に設定されるので、EXPLAINリクエスト修飾子の一部として指定する必要はありません。

STATIC EXPLAIN 
SELECT *
FROM t1, t2
WHERE t1.a1 < (SELECT MAX(t3.a3)
               FROM t3)
AND   t1.a1 = t2.a2;

これは、EXPLAIN出力の一部を示しています。

Explanation
------------------------------------------------------------------
This request is eligible for incremental planning and execution (IPE). The following is the static plan for the request. 
...
5) We do an all-AMPs SUM step to aggregate from OPTBASE_PCTDB.t3 by
   way of an all-rows scan with no residual conditions. Aggregate
   Intermediate Results are computed globally, then placed in Spool 3.
   The size of Spool 3 is estimated with high confidence to be 1 row
   (19 bytes). The estimated time for this step is 0.02 seconds.
6) We do an all-AMPs RETRIEVE step from Spool 3 (Last Use) by way of
   an all-rows scan into Spool 1 (all_amps), which is built locally
   on the AMPs. The size of Spool 1 is estimated with high
   confidence to be 1 row (25 bytes). The estimated time for this
   step is 0.00 seconds.
7) We do an all-AMPs DISPATCHER RETRIEVE step from Spool 1 (Last Use)
   by way of an all-rows scan and send the rows back to the
   Dispatcher.
8) We do an all-AMPs JOIN step from OPTBASE_PCTDB.t1 by way of a
   RowHash match scan with a condition of ("OPTBASE_PCTDB.t1.a1 <
   :%SSQ20"), which is joined to OPTBASE_PCTDB.t2 by way of a RowHash
   match scan with no residual conditions. OPTBASE_PCTDB.t1 and
   OPTBASE_PCTDB.t2 are joined using a sliding-window merge join,
   with a join condition of ("OPTBASE_PCTDB.t1.a1 =
   OPTBASE_PCTDB.t2.a2"). The input tables OPTBASE_PCTDB.t1 and
   OPTBASE_PCTDB.t2 will not be cached in memory, but
   OPTBASE_PCTDB.t1 is eligible for synchronized scanning. The
   result goes into Spool 5 (group_amps), which is built locally on
   the AMPs. The size of Spool 5 is estimated with no confidence to
   be 33,333,334 rows (2,166,666,710 bytes). The estimated time for
   this step is 1 minute and 10 seconds.
...

リクエストが増分計画および実行に適格なもののしきい値を満たさない場合のSTATIC EXPLAIN

この例では、説明されているリクエストがIPEに適格なものの、実行コスト用のシステム判別の特定のしきい値を満たさない場合のEXPLAINレポートについて示します。

この例では、システムが動的計画をレポートしないように設定されているとします。この場合、Teradata Databaseは、リクエストがIPEに適格であることを示す静的計画をレポートします。その際、STATICキーワードが暗黙的に設定されるので、EXPLAINリクエスト修飾子の一部として指定する必要はありません。

STATIC EXPLAIN 
SELECT *
FROM t1, t2
WHERE t1.a1 < (SELECT MAX(t3.a3)
               FROM t3)
AND   t1.a1 = t2.a2;

これは、EXPLAIN出力の一部を示しています。

Explanation
----------------------------------------------------------------------
This request is eligible for incremental planning and execution (IPE) but doesn't meet thresholds. The following is the static plan for the request. 
...
5) We do an all-AMPs SUM step to aggregate from OPTBASE_PCTDB.t3 by
   way of an all-rows scan with no residual conditions. Aggregate
   Intermediate Results are computed globally, then placed in Spool 3.
   The size of Spool 3 is estimated with high confidence to be 1 row
   (19 bytes). The estimated time for this step is 0.02 seconds.
6) We do an all-AMPs RETRIEVE step from Spool 3 (Last Use) by way of
   an all-rows scan into Spool 1 (all_amps), which is built locally
   on the AMPs. The size of Spool 1 is estimated with high
   confidence to be 1 row (25 bytes). The estimated time for this
   step is 0.00 seconds.
7) We do an all-AMPs DISPATCHER RETRIEVE step from Spool 1 (Last Use)
   by way of an all-rows scan and send the rows back to the
   Dispatcher.
8) We do an all-AMPs JOIN step from OPTBASE_PCTDB.t2 by way of a
   RowHash match scan, which is joined to OPTBASE_PCTDB.t1 by way of
   a RowHash match scan with a condition of ("OPTBASE_PCTDB.t1.a1 <
   :%SSQ20"). OPTBASE_PCTDB.t2 and OPTBASE_PCTDB.t1 are joined using
   a merge join, with a join condition of ("OPTBASE_PCTDB.t1.a1 =
   OPTBASE_PCTDB.t2.a2"). The result goes into Spool 5 (group_amps),
   which is built locally on the AMPs. The size of Spool 5 is
   estimated with no confidence to be 4 rows (260 bytes). The
   estimated time for this step is 0.02 seconds.
...

リクエストがIPEに適格なもののIPEが無効な場合のSTATIC EXPLAIN

IPEに適格なリクエストにSTATIC EXPLAINを実行依頼するもののIPEが無効な場合には、単にEXPLAINだけを実行依頼した場合に返されるのと同じレポート テキストになります。ただし、最初のステップの前に太字で強調表示されている追加の文は除きます。

STATIC EXPLAIN
SELECT *
FROM t1, t2
WHERE t1.a1 < (SELECT MAX(t3.a3)
               FROM t3)
AND   t1.a1 = t2.a2;

これは、EXPLAIN出力の一部を示しています。

Explanation
-----------------------------------------------------------------------
This request is eligible for incremental planning and execution (IPE). IPE is disabled. The following is the static plan for the request. 
...
5) We do an all-AMPs SUM step to aggregate from OPTBASE_PCTDB.t3 by
   way of an all-rows scan with no residual conditions. Aggregate
   Intermediate Results are computed globally, then placed in Spool 3.
   The size of Spool 3 is estimated with high confidence to be 1 row
   (19 bytes). The estimated time for this step is 0.02 seconds.
6) We do an all-AMPs RETRIEVE step from Spool 3 (Last Use) by way of
   an all-rows scan into Spool 1 (all_amps), which is built locally
   on the AMPs. The size of Spool 1 is estimated with high
   confidence to be 1 row (25 bytes). The estimated time for this
   step is 0.00 seconds.
7) We do an all-AMPs DISPATCHER RETRIEVE step from Spool 1 (Last Use)
   by way of an all-rows scan and send the rows back to the
   Dispatcher.
8) We do an all-AMPs JOIN step from OPTBASE_PCTDB.t2 by way of a
   RowHash match scan, which is joined to OPTBASE_PCTDB.t1 by way of
   a RowHash match scan with a condition of ("OPTBASE_PCTDB.t1.a1 <
   :%SSQ20"). OPTBASE_PCTDB.t2 and OPTBASE_PCTDB.t1 are joined using
   a merge join, with a join condition of ("OPTBASE_PCTDB.t1.a1 =
   OPTBASE_PCTDB.t2.a2"). The result goes into Spool 5 (group_amps),
   which is built locally on the AMPs. The size of Spool 5 is
   estimated with no confidence to be 4 rows (260 bytes). The
   estimated time for this step is 0.02 seconds.
...

リクエストが増分計画および実行に不適格な場合のSTATIC EXPLAIN

この例では、説明されているリクエストがIPEに不適格な場合のEXPLAINレポートについて示します。

この例では、システムが動的計画をレポートしないように設定されているとします。この例ではリクエストはIPEに不適格なので、Teradata DatabaseはIPEに関するリクエストの適格性については何もレポートしません。この例の場合、STATICキーワードが暗黙的に設定されるので、EXPLAINリクエスト修飾子の一部として指定する必要はありません。

このリクエストはIPEに不適格なので、レポートは、IPEが無効な場合にこの問合わせに対して生成されるレポートと同じになります。
STATIC EXPLAIN 
SELECT *
FROM t1
WHERE a3 > 10;
Explanation
-----------------------------------------------------------------
...
3) We do an all-AMPs RETRIEVE step from OPTBASE_PCTDB.t1 by way of an
   all-rows scan with a condition of ("OPTBASE_PCTDB.t1.a3 > 10") into
   Spool 1 (all_amps), which is built locally on the AMPs. The size of
   Spool 1 is estimated with no confidence to be 1 row (54 bytes). The
   estimated time for this step is 0.03 seconds.
...