楼主: onunix

[精华] 请教一下density的公式

[复制链接]
论坛徽章:
18
ITPUB元老
日期:2005-02-28 12:57:002010年世界杯参赛球队:南非
日期:2010-04-19 12:17:452010新春纪念徽章
日期:2010-03-01 11:05:01生肖徽章2007版:牛
日期:2009-11-02 17:04:55祖国60周年纪念徽章
日期:2009-10-09 08:28:00生肖徽章2007版:兔
日期:2008-09-22 19:33:40奥运会纪念徽章:蹦床
日期:2008-09-09 11:00:24奥运会纪念徽章:跳水
日期:2008-06-16 06:59:25ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44数据库板块每日发贴之星
日期:2007-10-08 01:03:42
11#
发表于 2008-9-18 08:31 | 只看该作者
density实际是反映一部分数据的特性,以前都是比如value1的density d1,value2的density d2的density就是(d1+d2)/2,但是d1只有1个只d2有100000个,那这样算的density客观吗?做二次方就是为了扩大特性,就是从0.1到0.2的200%的差异扩大到0.01到0.04的400%的差异,这样以后就尽可能少的出现两列density极其相近但是实际分布是相差非常之大而已。在没有histogram的时候能用尽可能准确的密度来决定到底那个条件来drive,算法这种东西都差不多,关键是只要都通用一样的算法就可以了

使用道具 举报

回复
论坛徽章:
3
授权会员
日期:2005-12-24 23:25:11ITPUB元老
日期:2007-07-19 00:13:00
12#
发表于 2008-9-22 13:16 | 只看该作者
个人理解是: (value1 rows / nonull rows + value2 rows/nonull rows + ... + valuen rows/nonull rows)/distinct value count

使用道具 举报

回复
论坛徽章:
2
2010新春纪念徽章
日期:2010-01-04 08:33:082010新春纪念徽章
日期:2010-03-01 11:20:05
13#
发表于 2009-4-8 20:29 | 只看该作者
Density is calculated as follows:

Pre 7.3
~~~~~~~

    Density = 1 / Number of distinct NON null values

The number of distinct NON-null values for a column (COL1) on table TABLE1
can be obtained as follows:

select distinct count(COL1)
from   TABLE1
where  COL1 is not null;


7.3+
~~~~

The Density calculation has been refined by the use of histograms. If
you have created histograms on your columns we can now use the histogram
information to give more accurate information. Otherwise the Density is
calculated as before. With histograms we can use information on
popular and non-popular values to determine the selectivity.

A non-popular value is one that does not span multiple bucket end points.
A popular value is one that spans multiple end points.

(Refer to <Note:50750.1> for details on histograms)

For non-popular values the density is calculated as the number of non-popular
values divided by the total number of values. Formula:

    Density =  Number of non-popular values
               ----------------------------
                  total number of values

We only use the density statistic for non-popular values.

Popular values calculate the selectivity of a particular column values by
using histograms as follows:

The Selectivity for popular values is calculated as the number of end points
spanned by that value divided by the total number of end points. Formula:

    Selectivity = Number of end points spanned by this value
                  ------------------------------------------
                         total number of end points

使用道具 举报

回复
论坛徽章:
2
2010新春纪念徽章
日期:2010-01-04 08:33:082010新春纪念徽章
日期:2010-03-01 11:20:05
14#
发表于 2009-4-8 20:33 | 只看该作者
i still have one question: what if i have a column that don't have histogram in my oracle 10g . how to compute that column's density?

使用道具 举报

回复
论坛徽章:
2
2010新春纪念徽章
日期:2010-01-04 08:33:082010新春纪念徽章
日期:2010-03-01 11:20:05
15#
发表于 2009-4-8 20:33 | 只看该作者
回家先搞

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
16#
发表于 2009-4-9 03:43 | 只看该作者
morong,

Thanks for sharing. But here's a friendly reminder. Whenever you post something not written by you, you must tell us the source for reason of copyright.

Message #13 is found at
http://asktom.oracle.com/pls/ask ... ON_ID:2969235095639

But I find that document to be not quite accurate for current versions of Oracle. For instance, on 10g, 10.2.0.2 and up, here's a good example of how density is calculated:

http://www.freelists.org/post/or ... case-of-histogram,3

Also I summarized some of the interesting points at
http://yong321.freeshell.org/oranotes/Histogram.html

Yong Huang

[ 本帖最后由 Yong Huang 于 2009-4-9 07:19 编辑 ]

使用道具 举报

回复
论坛徽章:
2
2010新春纪念徽章
日期:2010-01-04 08:33:082010新春纪念徽章
日期:2010-03-01 11:20:05
17#
发表于 2009-4-14 09:24 | 只看该作者
谢谢Yong Huang 的解答!!!

使用道具 举报

回复
论坛徽章:
1
授权会员
日期:2008-12-18 15:59:24
18#
发表于 2009-4-27 16:56 | 只看该作者
原帖由 Yong Huang 于 2009-4-9 03:43 发表
morong,

Thanks for sharing. But here's a friendly reminder. Whenever you post something not written by you, you must tell us the source for reason of copyright.

Message #13 is found at
http://asktom.oracle.com/pls/ask ... ON_ID:2969235095639

But I find that document to be not quite accurate for current versions of Oracle. For instance, on 10g, 10.2.0.2 and up, here's a good example of how density is calculated:

http://www.freelists.org/post/or ... n-case-of-histogram,3

Also I summarized some of the interesting points at
http://yong321.freeshell.org/oranotes/Histogram.html

Yong Huang



Yong Huang
能把原理、背景、应用场景在给大家介绍一下么!
最好使用中文并附有例子,这样大家理解更深刻!
好人做到底么!先替兄弟们谢谢你

使用道具 举报

回复
论坛徽章:
176
现任管理团队成员
日期:2011-05-07 01:45:08版主7段
日期:2012-07-05 02:21:03ITPUB长老会成员
日期:2015-05-07 15:11:10ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB牛人
日期:2010-10-25 12:41:322010数据库技术大会纪念徽章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:19
19#
发表于 2009-6-26 14:30 | 只看该作者
看看精华帖学习中! 看英文有点儿累哈~ 坚持

使用道具 举报

回复
论坛徽章:
176
现任管理团队成员
日期:2011-05-07 01:45:08版主7段
日期:2012-07-05 02:21:03ITPUB长老会成员
日期:2015-05-07 15:11:10ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB牛人
日期:2010-10-25 12:41:322010数据库技术大会纪念徽章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:19
20#
发表于 2009-6-26 14:39 | 只看该作者
学习!!!!

使用道具 举报

回复

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

本版积分规则 发表回复

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