Oracle high_value统计信息

问题描述 投票:0回答:1

考虑这种表格:

create table t (
   id number,       -- and many many other columns of course
   record_date date -- the date when the rows is inserted
);

在此表中,我们每小时添加400k行。每小时,我们使用最后一小时的数据启动查询。像SQL一样:

SELECT 
    ... 
FROM t
INNER JOIN ... -- t is joined with many other tables
INNER JOIN ... 
INNER JOIN ... 
INNER JOIN ... 
WHERE 
   t.record_date >= :my_current_date - 1/24
;

我们遇到的问题是,这种情况往往是计划不好。原因如下:

Oracle计算表的统计数据时,它将max(record_date)存储在名为high_value的统计信息中。因此,当SQL启动时,Oracle比较过滤器t.record_date >= :my_current_date - 1/24白色record_date列的high_value,并认为几乎不会返回任何行(而不是400k)。因此,以下连接的优化不能很好......

在这种情况下,最佳解决方案是什么?我可以用一个提示例如......

sql oracle query-optimization
1个回答
0
投票

我使用提示OPT_ESTIMATE(表t MIN = 400000),它到目前为止工作。谢谢piezol!

© www.soinside.com 2019 - 2024. All rights reserved.