テーブルのいずれかへの単一行の固有インデックス アクセスによる結合のカーディナリティの見積もり - Advanced SQL Engine - Teradata Database

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

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
2021年7月
Language
日本語
Last Update
2021-09-23
dita:mapPath
ja-JP/uqf1592445067244.ditamap
dita:ditavalPath
ja-JP/wrg1590696035526.ditaval
dita:id
B035-1142
Product Category
Software
Teradata Vantage

テーブルの任意のへの単一行の固有インデックス アクセスによる結合のカーディナリティの見積もりについて

結合のソース テーブルの1つで、固有インデックスを使用して単一行にアクセスする場合、最適化ルーチンは、最適化フェーズの間に行を検出し、検索した行の列の値で置換し、その置換に基づいてカーディナリティの見積もりを行ないます。

例えば、結合条件にfact_table.yr_wk BETWEEN calendar.ytd_beg_wk AND calendar.ytd_end_wkのようなフォームがあり、カレンダ テーブルにUPIまたはUSIを使用した単一行アクセス パスがある場合、最適化ルーチンは最適化フェーズの間にその行を取り出し、ytd_beg_wkおよびytd_end_wkに検索行の実際の値を置換し、その置換に基づいて結合のカーディナリティを見積もります。

EXPLAIN
SELECT *
FROM ordertbl, calendar
WHERE yr_wk BETWEEN ytd_beg_wk AND ytd_end_wk   <--  join predicate 
AND   calendar_date = 970101;    <--  UPI access to calendar table
...
  3)  We do a single-AMP RETRIEVE step from TPCD_OCES3.calendar by way 
      of the unique primary index "TPCD_OCES3.calendar.calendar_date = 
      DATE '1997-01-01'" with no residual conditions into Spool 2 
      (all_amps), which is duplicated on all AMPs.   The size of Spool 2
     is estimated with high confidence to be 14 rows (1,134 bytes).
     The estimated time for this step is 0.01 seconds.
  4) We do an all-AMPs JOIN step from Spool 2 (Last Use) by way of an
     all-rows scan, which is joined to TPCD_OCES3.order_75pct by way of
     an all-rows scan with no residual conditions.  Spool 2 and 
      TPCD_OCES3.order_75pct are joined using a product join, with a 
      join condition of ("(TPCD_OCES3.ordertbl.YR_WK >= Ytd_Beg_wk) 
      AND (TPCD_OCES3.ordertbl.YR_WK <= Ytd_End_wk)"). The input
     table TPCD_OCES3.ordertbl will not be cached in memory, but it
     is eligible for synchronized scanning. The result goes into Spool
     1 (group_amps), which is built locally on the AMPs. The size of
     Spool 1 is estimated with low confidence to be 365,114 rows (
     140,934,004 bytes). The estimated time for this step is 2.55
     seconds.

クエリー計画のステップ4で確認できるように、範囲結合述部のカーディナリティ見積もりは、ステップ3で検索されたカレンダ テーブルの行の値を代入することにより計算されます。