楼主: newkid

[翻译]Jonathan Lewis 关于直方图的系列文章(33楼更新至第三篇)

[复制链接]
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
51#
 楼主| 发表于 2014-1-28 01:02 | 只看该作者
刘大师回邮件说:
James,

I've corrected the article and added a comment about it.

The division should have been:  "(number of non-popular rows)/(number of non-popular values)"
And then the arithmetic should have been: 12/7 = 1.714


Regards

Jonathan Lewis
http://jonathanlewis.wordpress.com/all-postings

等会我将把译文相应修改一下。
谢谢oracledbacrs的较真!

使用道具 举报

回复
论坛徽章:
0
52#
发表于 2014-2-8 15:31 | 只看该作者
不好意思,最近研究11g采样过程算法回头再来读这文章,还是发现一点小问题,撇开10g 9i来讲
第二章作者这样写道
我们有一千万行数据——并且我们为了创建等高直方图所做的第一件事就是对数据排序,所以第一步是相当耗费资源的。如果我们对数据采样,这会减少排序的数据量——但是这个采样可能会漏掉很多值,以至于Oracle以为能够创建一个频度直方图——那样就会使得优化器对某些实际上有几千行的值做出过低的估算。

疑问是,既然oracle11g采用新的ndv算法能够在收集直方图信息前就准确估算到字段的ndv值,那为什么会有‘以至于Oracle以为能够创建一个频度直方图'这种说法呢?求解,在我看来能够收集到准确的ndv值就能够迅速判断最优的直方图选择,假设ndv估算值是300,明显〉254,难道还会像作者说的那样尝试去创建频率直方图吗?

使用道具 举报

回复
论坛徽章:
0
53#
发表于 2014-2-8 15:37 | 只看该作者
顺便问问lz有没有直方图信息收集过程详解的文章来瞧瞧,给个连接也行,谢谢

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
54#
 楼主| 发表于 2014-2-10 23:55 | 只看该作者
oracledbacrs 发表于 2014-2-8 15:31
不好意思,最近研究11g采样过程算法回头再来读这文章,还是发现一点小问题,撇开10g 9i来讲
第二章作者这样 ...

这里说的是采样的情况,如果你的数据分布很不均匀,采样到的部分恰好涵盖了很少的值,那么即使用NDV也无法正确估算出全表的情况。如果你采样比例设为100%当然就不会了。

你要的文章我也没有见过,如果有研究精神,可以去反编译DBMS_STATS包,或者跟踪一下它产生的SQL。

使用道具 举报

回复
论坛徽章:
0
55#
发表于 2014-2-11 10:34 | 只看该作者
newkid 发表于 2014-2-10 23:55
这里说的是采样的情况,如果你的数据分布很不均匀,采样到的部分恰好涵盖了很少的值,那么即使用NDV也无法 ...

不是吧?11g中,是在分析表的统计信息时,就同时分析了除了直方图之外的所有基础字段统计信息,这个分析过程是个不采样的全表扫描,所以在分析直方图统计信息的时候,其实oracle已经知道了字段精确ndv值了,如果需要文章我可以给你链接

使用道具 举报

回复
论坛徽章:
0
56#
发表于 2014-2-11 10:44 | 只看该作者
oracledbacrs 发表于 2014-2-11 10:34
不是吧?11g中,是在分析表的统计信息时,就同时分析了除了直方图之外的所有基础字段统计信息,这个分析过 ...

补充,使用新的ndv算法的前提是全表扫描

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
57#
 楼主| 发表于 2014-2-11 11:06 | 只看该作者
http://jonathanlewis.files.wordp ... stinct-sampling.pdf
3.3 Estimating table level NDV from sample

可见不一定是全表扫描,表级数据仍然是估算的。

使用道具 举报

回复
论坛徽章:
0
58#
发表于 2014-2-11 12:08 | 只看该作者
newkid 发表于 2014-2-11 11:06
http://jonathanlewis.files.wordpress.com/2011/12/one-pass-distinct-sampling.pdf
3.3 Estimating tabl ...

In Oracle Database 11g, we use a completely different approach for gathering basic column statistics. We issue the following query to gather basic column statistics (again this is a simplified version for illustration purpose).



Query 2: Query Gathering Basic Column Statistics Using AUTO_SAMPLE_SIZE in 11g

You will notice in the new basic column statistics gathering query, no sampling clause is used. Instead we do a full table scan. Also, there is no more count(distinct C1) to gather NDV for C1. Instead, during the execution we inject a special statistics gathering row source to this query. The special gathering row source uses a one-pass, hash-based distinct algorithm to gather NDV. More information on how this algorithm works can be found in the paper, “efficient and scalable statistics gathering for large databases in Oracle 11g”. The algorithm requires a full scan of the data, uses a bounded amount of memory and yields a highly accurate NDV that is nearly identical to a 100 percent sampling (can be proven mathematically). The special statistics gathering row source also gathers the number of rows, number of nulls and average column length on the side. Since we do a full scan on the table, the number of rows, average column length, minimal and maximal values are 100% accurate.
嗯,研究下你的谢了

使用道具 举报

回复
论坛徽章:
0
59#
发表于 2014-2-11 12:27 | 只看该作者
newkid 发表于 2014-2-11 11:06
http://jonathanlewis.files.wordpress.com/2011/12/one-pass-distinct-sampling.pdf
3.3 Estimating tabl ...

哥们你给的链接不能下载啊,能不能直接发我邮箱啊oracledbacrs@hotmail.com谢了啊

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
60#
 楼主| 发表于 2014-2-12 00:27 | 只看该作者
你贴的引文说的是使用AUTO_SAMPLE_SIZE的情况。
另外,49楼的引文说的是采用排序的方法,不是采用新的NDV的方法。
我在公司没法往外发东西,等回家了再把文章上传。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表