如何让TD避免使用单功放回收?
How to make TD to avoid using single amp retrieve?
我有这样的疑问:
select * from view -- not very simple logic
where report_date between date'2016-01-01' and date'2016-12-31';
那我取大时间间隔:
TD选择这样的方案:
3) We do an all-AMPs RETRIEVE step from Spool 25 (Last Use) by way of
an all-rows scan with a condition of ("(REPORT_DT >= DATE
'2016-01-01') AND (REPORT_DT <= DATE '2016-12-31')") into Spool 36
(all_amps) (compressed columns allowed) fanned out into 3 hash
但如果我采用的间隔不是那么大,它会决定对每个数据采用简单的放大器检索:
select * from view -- not very simple logic
where report_date between date'2016-06-01' and date'2016-12-31';
239) We do a single-AMP RETRIEVE step from
tableName1 by way of the unique
primary index "tableName1.gregor_dt =
DATE '2016-08-08'" extracting row ids only with no residual
conditions locking row for access into Spool 43 (group_amps),
which is built locally on that AMP. The size of Spool 43 is
estimated with low confidence to be 221 rows. The estimated time
for this step is 0.00 seconds.
1) 由于假脱机问题,第二次查询失败。如何强制 teradata 使用第一个计划?
upd1:
- 没有双重转换,只是从一种日期格式转换为
另一个。
- 两个计划都使用重新分配,除了指出的地方外我没有区别。
- TD 高估了行数,最多 2-3 次(我在评论中给出了错误的信息)
- 我们在 DEV 中拥有几乎相同数量的信息和统计数据。然而,DEV 服务器的 AMPS 和节点数量要少 2 倍,而且每个放大器的功能明显不那么强大。然而,开发中的 TD 开始决定使用第一个 "good" 计划来缩短间隔。怎么才能"fool" PROD server 一下呢?)
我做到了!要让它工作只需要欺骗 TD 两次)
query 的思路是取 table,然后乘积加入 Sys_Calendar
,然后应用 row_number 和一些逻辑。降低统计数据可能有效,但 TD 可能会使用抽样和兑现,这最终会破坏您的工作。这就是我在视图中应用 expand
+ 子查询的原因:
...
FROM ( SEL cdate as cdate FROM (SELECT DISTINCT BEGIN (tp) (NAMED cdate)
FROM Sys_Calendar.CALDATES
EXPAND ON PERIOD (date '2014-01-01', current_date + 1) AS tp
BY INTERVAL '1' DAY FOR PERIOD (date '2014-01-01', current_date + 1)
) A) cldr
...
然后我可以使用 where
条款申请和我想要的期限。
新计划比 "good" 计划快 15 倍!
我有这样的疑问:
select * from view -- not very simple logic
where report_date between date'2016-01-01' and date'2016-12-31';
那我取大时间间隔:
TD选择这样的方案:
3) We do an all-AMPs RETRIEVE step from Spool 25 (Last Use) by way of
an all-rows scan with a condition of ("(REPORT_DT >= DATE
'2016-01-01') AND (REPORT_DT <= DATE '2016-12-31')") into Spool 36
(all_amps) (compressed columns allowed) fanned out into 3 hash
但如果我采用的间隔不是那么大,它会决定对每个数据采用简单的放大器检索:
select * from view -- not very simple logic
where report_date between date'2016-06-01' and date'2016-12-31';
239) We do a single-AMP RETRIEVE step from
tableName1 by way of the unique
primary index "tableName1.gregor_dt =
DATE '2016-08-08'" extracting row ids only with no residual
conditions locking row for access into Spool 43 (group_amps),
which is built locally on that AMP. The size of Spool 43 is
estimated with low confidence to be 221 rows. The estimated time
for this step is 0.00 seconds.
1) 由于假脱机问题,第二次查询失败。如何强制 teradata 使用第一个计划?
upd1:
- 没有双重转换,只是从一种日期格式转换为 另一个。
- 两个计划都使用重新分配,除了指出的地方外我没有区别。
- TD 高估了行数,最多 2-3 次(我在评论中给出了错误的信息)
- 我们在 DEV 中拥有几乎相同数量的信息和统计数据。然而,DEV 服务器的 AMPS 和节点数量要少 2 倍,而且每个放大器的功能明显不那么强大。然而,开发中的 TD 开始决定使用第一个 "good" 计划来缩短间隔。怎么才能"fool" PROD server 一下呢?)
我做到了!要让它工作只需要欺骗 TD 两次)
query 的思路是取 table,然后乘积加入 Sys_Calendar
,然后应用 row_number 和一些逻辑。降低统计数据可能有效,但 TD 可能会使用抽样和兑现,这最终会破坏您的工作。这就是我在视图中应用 expand
+ 子查询的原因:
...
FROM ( SEL cdate as cdate FROM (SELECT DISTINCT BEGIN (tp) (NAMED cdate)
FROM Sys_Calendar.CALDATES
EXPAND ON PERIOD (date '2014-01-01', current_date + 1) AS tp
BY INTERVAL '1' DAY FOR PERIOD (date '2014-01-01', current_date + 1)
) A) cldr
...
然后我可以使用 where
条款申请和我想要的期限。
新计划比 "good" 计划快 15 倍!