对于有列数据非常倾斜的表,做直方图分析很重要,直方图主要讨论的是数据在列上的分布情况。
可以看出,dbms_stats包默认已对id列做了直方图分析。CBO根据直方图信息估算id=99的记录只有1行,这很正确,所以选择索引。
CBO根据直方图信息估算id=1的记录有72483行,几乎和表记录数一致,所以选择了全表扫描。
在这里,仅仅删除直方图的信息,保留表和索引的分析信息
删除直方图后的执行计划
不管谓词id=99还是id=1,CBO估算行数均为725行,而实际id=99的记录只有1条,id=1的记录基本为全部的表记录,所以CBO均使用索引是错的。
在起初,我对T进行分析时,遗漏了estimate_percent=>100这一参数的设置,以至于不管是对谓词id=1还是id=99执行计划均采用全表扫描。我想是因为对id列上的数据分布情况没有分析出来(或者产生了分析信息是错误的),所以应该根据我们的数据量来设置estimate_percent值。
oracle 11gr2 document中对于estimate_percent的解释:
estimate_percent
Percentage of rows to estimate (NULL means compute): The valid range is [0.000001,100]. Use the constant DBMS_STATS.AUTO_SAMPLE_SIZE to have Oracle determine the appropriate sample size for good statistics. This is the default.The default value can be changed
using the SET_DATABASE_PREFS Procedure, SET_GLOBAL_PREFS Procedure, SET_SCHEMA_PREFS Procedure and SET_TABLE_PREFS Procedure.
method_opt
Accepts:
FOR ALL [INDEXED | HIDDEN] COLUMNS [size_clause]
FOR COLUMNS [size clause] column|attribute [size_clause] [,column|attribute [size_clause]...]
size_clause is defined as size_clause := SIZE {integer | REPEAT | AUTO | SKEWONLY}
- integer : Number of histogram buckets. Must be in the range [1,254].
- REPEAT : Collects histograms only on the columns that already have histograms.
- AUTO : Oracle determines the columns to collect histograms based on data distribution and the workload of the columns.
- SKEWONLY : Oracle determines the columns to collect histograms based on the data distribution of the columns.
The default is FOR ALL COLUMNS SIZE AUTO.The default value can be changed using the SET_PARAM Procedure.
在oracle中要删除直方图信息就是设置bucket的数据为1,可以使用如下两个命令来实现:
analyze table 表 compute statistics for table for columns 列 size 1;
exec dbms_stats.gather_table_stats(ownname => '',tabname=>'',cascade=>true, method_opt=>'for columns 列 size 1');
skewonly 选项的时间性很强,因为它检查每个索引中每列值的分布。如果 dbms_stats 发现一个索引中具有不均匀分布的列,它将为该索引创建直方图,以帮助基于成本的 SQL 优化器决定是使用索引还是全表扫描访问。
begin
dbms_stats. gather_table_stats (
ownname => '',
tabname=>'',
estimate_percent =>dbms_stats.auto_sample_size,
method_opt => 'for columns 列 size skewonly',
cascade=>true,
degree => 2);
end;
cascade
Gather statistics on the indexes for this table. Index statistics gathering is not parallelized. Using this option is equivalent to running the GATHER_INDEX_STATS Procedure on each of the table's indexes. Use the constant DBMS_STATS.AUTO_CASCADE to have Oracle
determine whether index statistics to be collected or not. This is the default. The default value can be changed using theSET_PARAM Procedure.
官方文档:http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/stats.htm#PFGRF30103
相关阅读
柱状图(Histogram),绑定变量,bind
peeking,cursor_sharing 之间的关系1 柱状图
柱状图(Histogram),绑定变量,bind
peeking,cursor_sharing 之间的关系2 绑定变量与柱状图
柱状图(Histogram),绑定变量,bind
peeking,cursor_sharing 之间的关系3 柱状图与cursor_sharing
分享到:
相关推荐
基于Matlab直方图Histogram的人脸识别程序-Processed histogram based Face Recognition.part3.rar 基于Matlab 直方图Histogram的人脸识别程序 因为数据库图片太大,所以分成几个压缩文件。 Face ...
基于Matlab直方图Histogram的人脸识别程序-Processed histogram based Face Recognition.part2.rar 基于Matlab 直方图Histogram的人脸识别程序 因为数据库图片太大,所以分成几个压缩文件。 Face ...
基于Matlab 直方图Histogram的人脸识别程序:给出人脸图像库,包含训练及测试模块,最终给出识别结果。文件中附介绍。
文章内容转载自网络。 从直方图的概念 直方图的作用、使用场合……等内容深入分析了oracle直方图,并给出了操作实例,建议收藏备查。
基于Matlab直方图Histogram的人脸识别程序-Processed histogram based Face Recognition.part1.rar 基于Matlab 直方图Histogram的人脸识别程序 因为数据库图片太大,所以分成几个压缩文件。 Face ...
基于Matlab直方图Histogram的人脸识别程序-Processed histogram based Face Recognition.part4.rar 基于Matlab 直方图Histogram的人脸识别程序 因为数据库图片太大,所以分成几个压缩文件。 Face ...
unity插件 直方图 Histogram.unitypackage
总结论坛中的人脸检测和识别有多个测试库-基于Matlab 直方图Histogram的人脸识别程序.rar 搜索过,论坛中的人脸检测和识别的代码挺多的,但是有点乱,没有总结……于是我总结一下论坛中的关于人脸检测和识别的方法...
Recognizing objects from large image databases, histogram based methods have proved simplicity and usefulness in last decade. Initially, this idea was based on color histograms that were launched by ...
【Maclean Liu技术分享】拨开Oracle CBO优化器迷雾,探究Histogram直方图之秘_0321.pdf
本源代码首先实现普通的直方图均衡化,再实现灰度级之间的均匀分布,可以有效的解决直方图均衡化过程中的灰度断层现象。使得图像更加的柔和,直方图分布更均匀。
实现了对图像直方图的操作,如直方图显示,直方图匹配,直方图均衡等
直方图统计,opencv截取的视频帧,对话框中的picture控件
在机器人技术中,Vector Field Histogram(VFH,向量场直方图)是Johann Borenstein和Yoram Koren在1991年提出的一种实时路径规划算法。VFH通过所谓的直方图网格利用机器人环境的统计表示,因此非常重视处理来自...
OpenCV Histogram 直方图学习
用matlab实现自编直方图程序并与matlab自带直方图函数进行比较,以及实现直方图均衡
图像直方图(英语:Image Histogram)是用以表示数字图像中亮度分布的直方图,标绘了图像中每个亮度值的像素数。可以借助观察该直方图了解需要如何调整亮度分布。这种直方图中,横坐标的左侧为纯黑、较暗的区域,而...
直方图是反映一幅图像中的灰度级与出现这种灰度的概率之间的关系图。
直方图(Histogram)又称质量分布图。是一种统计报告图,由一系列高度不等的纵向条纹或线段表示数据分布的情况。 一般用横轴表示数据类型,纵轴表示分布情况。 直方图是数值数据分布的精确图形表示。 这是一个连续变量...
实现图片的直方图均衡化,结合vs2019+opencv加以实现,附带测试图片