Выбор вида вызывает ошибку TDWM. Плохой план объяснения? Первопричина? - PullRequest
0 голосов
/ 15 января 2020

Кто-нибудь может мне помочь настроить View на основе плана объяснения?

Выбор причины просмотра TDWM Ошибка. Это использует больше чем> 100 КБ процессора. Мне трудно читать объяснительный план в Teradata, так что вы, ребята, можете помочь мне решить проблему?

У меня есть первичный индекс IDN, а также вторичный индекс PARENT_ID.

 This query is optimized using type 2 profile nonested_cost, profileid
 10003.
  1) First, we lock 'table_name' in view 'view_name' in TD_MAP1 for read 
     on a reserved RowHash to prevent global deadlock.
  2) Next, we lock 'table_name' in view 'view_name' in TD_MAP1 for read.
  3) We do an all-AMPs RETRIEVE step in TD_MAP1 from 'table_name' in view
     'view_name' by way of an all-rows scan with a condition of (
     "'table_name' in view 'view_name'.A = 'X'") into Spool 7 (all_amps), 
     which is redistributed by the hash code of ('table_name'.IDN) to all 
     AMPs in TD_Map1.  Then we do a SORT to order Spool 7 by row hash.  
     The size of Spool 7 is estimated with high confidence to be 562,323 
     rows (16,307,367 bytes).  The estimated time for this step is 0.07 
     seconds.
  4) We do an all-AMPs JOIN step in TD_MAP1 from 'table_name' in view
     'view_name' by way of a RowHash match scan with a condition of (
     "((CAST(('table_name' in view 'view_name'.DATE) AS DATE))>=DATE 
     '2018-01-01') AND (('table_name' in view 'view_name'.A IN ('X','Y',
     'Z')) AND ('table_name' in view 'view_name'.C <> 'XXX'))"), which 
     is joined to Spool 7 (Last Use) by way of a RowHash match scan.
     'table_name' and Spool 7 are joined using a merge join, with a join 
     condition of ("'table_name'.PARENT_ID = IDN").  The result goes into 
     Spool 6 (all_amps), which is built locally on the AMPs.  The size of 
     Spool 6 is estimated with low confidence to be 562,323 rows 
     (308,715,327 bytes).  The estimated time for this step is 0.03 
     seconds.
  5) We do an all-AMPs RETRIEVE step in TD_Map1 from Spool 6 by way of
     an all-rows scan with a condition of ("(NOT (R.K0 IS NULL )) AND
     ((NOT (R.K2 IS NULL )) AND (R.K0D <= R.K2D ))") into Spool 2
     (all_amps), which is built locally on the AMPs.  The size of Spool
     2 is estimated with no confidence to be 562,323 rows (308,715,327
     bytes).  The estimated time for this step is 0.04 seconds.
  6) We do an all-AMPs RETRIEVE step in TD_Map1 from Spool 6 (Last Use)
     by way of an all-rows scan with a condition of (
     "TD_RECURSIVE_REF.DEPTH <= 264") into Spool 8 (all_amps), which is
     redistributed by the hash code of (
    'table_name'.IDN)
     to all AMPs in TD_Map1.  The size of Spool 8 is estimated with no
     confidence to be 562,323 rows (297,468,867 bytes).  The estimated
     time for this step is 0.14 seconds.
  7) We do an all-AMPs JOIN step in TD_MAP1 from 'table_name' in view
     'view_name' by way of an all-rows scan with a condition of (
     "'table_name' in view 'view_name'.PLANT IN ('X','Y,'Z')"), which 
     is joined to Spool 8 (Last Use) by way of an all-rows scan.
    'table_name' and Spool 8 are joined using a single partition hash 
     join, with a join condition of ("K1 ='table_name'.ID"). The result 
     goes into Spool 9 (all_amps), which is built locally on the AMPs.  
     The size of Spool 9 is estimated with no confidence to be 562,323 
     rows (308,715,327 bytes).  The estimated time for this step is 0.06 
     seconds.
  8) We do an all-AMPs RETRIEVE step in TD_Map1 from Spool 9 (Last Use)
     by way of an all-rows scan into Spool 6 (all_amps), which is built
     locally on the AMPs.  The size of Spool 6 is estimated with no
     confidence to be 28,678,473 rows (15,744,481,677 bytes).  The
     estimated time for this step is 0.04 seconds.  If one or more rows
     are inserted into spool 6, then go to step 5.
  9) We do an all-AMPs RETRIEVE step in TD_Map1 from Spool 2 (Last Use)
     by way of an all-rows scan with a condition of ("(NOT (R.K0 IS
     NULL )) AND ((NOT (R.K2 IS NULL )) AND (R.K0D <= R.K2D ))") into
     Spool 5 (all_amps), which is built locally on the AMPs.  The size
     of Spool 5 is estimated with no confidence to be 28,678,473 rows (
     14,253,201,081 bytes).  The estimated time for this step is 1.56
     seconds.
 10) We do an all-AMPs STAT FUNCTION step in TD_Map1 from Spool 5 (Last
     Use) by way of an all-rows scan into Spool 12 (Last Use), which is
     assumed to be redistributed by value to all AMPs in TD_Map1.  The
     result rows are put into Spool 10 (all_amps), which is built
     locally on the AMPs.  The size is estimated with no confidence to
     be 28,678,473 rows (14,482,628,865 bytes).
 11) We do an all-AMPs RETRIEVE step in TD_Map1 from Spool 10 (Last
     Use) by way of an all-rows scan into Spool 3 (used to materialize
     view, derived table, table function or table operator X)
     (all_amps), which is redistributed by the hash code of (Field_35
     (INTEGER), Field_34, K2D, K2Q, K2DI, K2MU, K2MT, K2MN, K2M, K2BD,
     K2PSN, K2PUN, K2MCN, K2MC, K2BN, K2PN, K2PC, K0D, K0Q, K0DI, K0MU,
     K0MT, K0MN, K0M, K0BD, K0PSN, K0PUN, K0MCN, K0MC, K0BN, K0PN, K0PC,
     K2, K0) to all AMPs in TD_Map1.  Then we do a SORT to order Spool
     3 by the sort key in spool field1 eliminating duplicate rows.  The
     size of Spool 3 is estimated with no confidence to be 21,508,855
     rows (35,554,137,315 bytes).  The estimated time for this step is
     7.09 seconds.
 12) We do an all-AMPs SUM step in TD_Map1 to aggregate from Spool 3
     (Last Use) by way of an all-rows scan with a condition of (
     "X.END_LAST_MOVE = 1"), and the grouping identifier in field
     1.  Aggregate Intermediate Results are computed globally, then
     placed in Spool 4 in TD_Map1.  The size of Spool 4 is estimated
     with no confidence to be 16,131,642 rows (25,504,126,002 bytes).
     The estimated time for this step is 38.74 seconds.
 13) Finally, we send out an END TRANSACTION step to all AMPs involved
     in processing the request.
  -> The contents of Spool 4 are sent back to the user as the result of
     statement 1.  

1 Ответ

0 голосов
/ 15 января 2020

Не видя ваш запрос и базовые таблицы / структуры, вот несколько общих советов:

  • настройка базового представления SQL для выполнения любых объединений, агрегаций (то есть GROUP BY) или OLAP функций, основанных на столбцах PI этих таблиц (т.е. на шаге 10 у вас есть all-AMPs STAT FUNCTION, который предлагает функцию OLAP, SAMPLE, or TOP)
  • есть ссылка на TD_RECURSIVE_REF.DEPTH <= 264, которая предполагает, что у вас есть рекурсивный запрос; если вы можете, попробуйте уменьшить значение «глубины»
  • Шесть шагов в вашем EXPLAIN говорят «нет уверенности», поэтому может быть полезно сделать DIAGNOSTIC HELPSTATS ON FOR SESSION;, а затем запустить EXPLAIN по вашему запросу. Внизу EXPLAIN вы получите список рекомендуемых статистических данных для сбора. Запустите EXPLAIN, соберите некоторую статистику, затем снова выполните EXPLAIN, чтобы посмотреть, изменился ли план запроса
  • собрать статистику по любым вторичным индексам, чтобы увеличить вероятность их использования

Вот несколько общих советов по физической настройке:

  • выбор столбцов первичного индекса для доступа и равномерного распределения
  • просмотр сжатия на основе значений (меньшие строки -> меньше операций ввода-вывода и буферизации)
  • посмотрите на разделение первичного индекса (PPI), если это возможно
...