狠狠撸

狠狠撸Share a Scribd company logo
分区表与统计信息
 Kamus@ACOUG
About ACOUG
?   ACOUG: All China Oracle User Group
?   http://acoug.org
About Me
?   Kamus 张乐奕
?   http://www.dbform.com
?   PCCW -> Oracle -> Enmou
?   将技术作为艺术对待
?   以兴奋的状态面对知识
来源
?   Doug Burns
?   http://oracledoug.com/
?   Statistics on Partitioned Tables
Global Statistics
?   以默认方式收集统计信息
    exec dbms_stats.gather_table_stats('KAMUS', 'TAB_PART',
      GRANULARITY => 'DEFAULT');
?   What is Default
    ?   granularity => ' DEFAULT ' = 'GLOBAL AND PARTITION'
    ?   包括表,分区的全体统计信息,但是不包括子分区

?   Oracle10gR2 ,Oracle11gR1/R2
    ?   granularity => ' AUTO'
    ?   按照分区类型决定,可能包括表,分区,子分区的所
        有全体统计信息
Aggregated Statistics
?   只收集子分区的统计信息
    exec dbms_stats.delete_table_stats('KAMUS', 'TAB_PART');
    exec dbms_stats.gather_table_stats('KAMUS','TAB_PART',
      GRANULARITY => 'SUBPARTITION');


?   聚合统计信息
    ?   减少统计信息生成时的系统开销
坏的情况
?   新加载数据
?   收集有数据变化的子分区统计信息
    exec dbms_stats.gather_table_stats('KAMUS','TAB_PART',
      GRANULARITY => 'SUBPARTITION', PARTNAME =>
      'P_20100206_GROT');

?   聚合统计信息正确
?   列上的统计信息呢?NDV
    ?   在11gR2中得以改善 (Not Tested):
        APPROX_GLOBAL AND PARTITION
还有坏的情况
?   增加子分区
    ALTER TABLE TAB_PART
    ADD PARTITION P_20100208 VALUES LESS THAN (20100209);
?   新加载数据
?   收集有数据变化的某个子分区统计信息
    exec dbms_stats.gather_table_stats('KAMUS','TAB_PART',
      GRANULARITY => 'SUBPARTITION', PARTNAME =>
      'P_20100208_GROT');
?   聚合统计信息?
    ?   在每次收集子分区统计信息时都会聚合
    ?   在删除子分区统计信息时不会发生聚合
还有更坏的情况
?   新创建的分区表没有任何数据
?   收集分区统计信息
    exec dbms_stats.gather_table_stats('KAMUS','TAB_PART',
      GRANULARITY => 'PARTITION');

?   新加载数据
?   聚合?
    ?   收集子分区的统计信息?
    ?   收集全部子分区的统计信息?
WHY

?   真实全局统计信息 VS. 聚合全局统计信息

?   真实 WIN!
Conclusion

?   知道我们在做什么再去做!

?   如果只选择收集SUBPARTITION统计信息,
    那么要确认聚合统计信息会正确生成。
问   答

More Related Content

Similar to Stats partitioned table (16)

翱谤补肠濒别中比对2张表之间数据是否一致的几种方法
翱谤补肠濒别中比对2张表之间数据是否一致的几种方法翱谤补肠濒别中比对2张表之间数据是否一致的几种方法
翱谤补肠濒别中比对2张表之间数据是否一致的几种方法
maclean liu
?
自下而上的数据仓库构建方法
自下而上的数据仓库构建方法自下而上的数据仓库构建方法
自下而上的数据仓库构建方法
tongxiaojun
?
辞谤补肠濒别优化器星型转换
辞谤补肠濒别优化器星型转换辞谤补肠濒别优化器星型转换
辞谤补肠濒别优化器星型转换
maclean liu
?
淘宝数据魔方的系统架构 -长林
淘宝数据魔方的系统架构 -长林淘宝数据魔方的系统架构 -长林
淘宝数据魔方的系统架构 -长林
Shaoning Pan
?
Build 1 trillion warehouse based on carbon data
Build 1 trillion warehouse based on carbon dataBuild 1 trillion warehouse based on carbon data
Build 1 trillion warehouse based on carbon data
boxu42
?
杰表.2008报表实例研究
杰表.2008报表实例研究杰表.2008报表实例研究
杰表.2008报表实例研究
guest07ce405
?
分区表基础知识培训
分区表基础知识培训分区表基础知识培训
分区表基础知识培训
maclean liu
?
数据库原理第叁章
数据库原理第叁章数据库原理第叁章
数据库原理第叁章
strun
?
11, OCP - awr & alert system
11, OCP - awr & alert system11, OCP - awr & alert system
11, OCP - awr & alert system
ted-xu
?
数据库性能诊断的七种武器
数据库性能诊断的七种武器数据库性能诊断的七种武器
数据库性能诊断的七种武器
Leyi (Kamus) Zhang
?
Enterprise Data Lake in Action
Enterprise Data Lake in ActionEnterprise Data Lake in Action
Enterprise Data Lake in Action
Jazz Yao-Tsung Wang
?
Something about oracle joins
Something about oracle joinsSomething about oracle joins
Something about oracle joins
mysqlops
?
Catia v5 CAM enhancement
Catia v5 CAM enhancementCatia v5 CAM enhancement
Catia v5 CAM enhancement
Jimmy Chang
?
惭测厂蚕尝资料表正规化草稿
惭测厂蚕尝资料表正规化草稿惭测厂蚕尝资料表正规化草稿
惭测厂蚕尝资料表正规化草稿
jiannrong
?
MySQL 6.0 下的cluster + replicate - 20080220
MySQL 6.0 下的cluster + replicate - 20080220MySQL 6.0 下的cluster + replicate - 20080220
MySQL 6.0 下的cluster + replicate - 20080220
Jinrong Ye
?
翱谤补肠濒别中比对2张表之间数据是否一致的几种方法
翱谤补肠濒别中比对2张表之间数据是否一致的几种方法翱谤补肠濒别中比对2张表之间数据是否一致的几种方法
翱谤补肠濒别中比对2张表之间数据是否一致的几种方法
maclean liu
?
自下而上的数据仓库构建方法
自下而上的数据仓库构建方法自下而上的数据仓库构建方法
自下而上的数据仓库构建方法
tongxiaojun
?
辞谤补肠濒别优化器星型转换
辞谤补肠濒别优化器星型转换辞谤补肠濒别优化器星型转换
辞谤补肠濒别优化器星型转换
maclean liu
?
淘宝数据魔方的系统架构 -长林
淘宝数据魔方的系统架构 -长林淘宝数据魔方的系统架构 -长林
淘宝数据魔方的系统架构 -长林
Shaoning Pan
?
Build 1 trillion warehouse based on carbon data
Build 1 trillion warehouse based on carbon dataBuild 1 trillion warehouse based on carbon data
Build 1 trillion warehouse based on carbon data
boxu42
?
杰表.2008报表实例研究
杰表.2008报表实例研究杰表.2008报表实例研究
杰表.2008报表实例研究
guest07ce405
?
分区表基础知识培训
分区表基础知识培训分区表基础知识培训
分区表基础知识培训
maclean liu
?
数据库原理第叁章
数据库原理第叁章数据库原理第叁章
数据库原理第叁章
strun
?
11, OCP - awr & alert system
11, OCP - awr & alert system11, OCP - awr & alert system
11, OCP - awr & alert system
ted-xu
?
数据库性能诊断的七种武器
数据库性能诊断的七种武器数据库性能诊断的七种武器
数据库性能诊断的七种武器
Leyi (Kamus) Zhang
?
Something about oracle joins
Something about oracle joinsSomething about oracle joins
Something about oracle joins
mysqlops
?
Catia v5 CAM enhancement
Catia v5 CAM enhancementCatia v5 CAM enhancement
Catia v5 CAM enhancement
Jimmy Chang
?
惭测厂蚕尝资料表正规化草稿
惭测厂蚕尝资料表正规化草稿惭测厂蚕尝资料表正规化草稿
惭测厂蚕尝资料表正规化草稿
jiannrong
?
MySQL 6.0 下的cluster + replicate - 20080220
MySQL 6.0 下的cluster + replicate - 20080220MySQL 6.0 下的cluster + replicate - 20080220
MySQL 6.0 下的cluster + replicate - 20080220
Jinrong Ye
?

More from xlight (20)

淘宝无线电子商务数据报告
淘宝无线电子商务数据报告淘宝无线电子商务数据报告
淘宝无线电子商务数据报告
xlight
?
New zealand bloom filter
New zealand bloom filterNew zealand bloom filter
New zealand bloom filter
xlight
?
Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0
xlight
?
Oracle ha
Oracle haOracle ha
Oracle ha
xlight
?
Oracle 高可用概述
Oracle 高可用概述Oracle 高可用概述
Oracle 高可用概述
xlight
?
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
xlight
?
颁/颁++与尝耻补混合编程
颁/颁++与尝耻补混合编程颁/颁++与尝耻补混合编程
颁/颁++与尝耻补混合编程
xlight
?
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed SystemsGoogle: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
xlight
?
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed SystemsGoogle: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
xlight
?
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile ServiceHigh Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
xlight
?
PgSQL vs MySQL
PgSQL vs MySQLPgSQL vs MySQL
PgSQL vs MySQL
xlight
?
SpeedGeeks
SpeedGeeksSpeedGeeks
SpeedGeeks
xlight
?
GOOGLE: Designs, Lessons and Advice from Building Large Distributed Systems
GOOGLE: Designs, Lessons and Advice from Building Large   Distributed Systems GOOGLE: Designs, Lessons and Advice from Building Large   Distributed Systems
GOOGLE: Designs, Lessons and Advice from Building Large Distributed Systems
xlight
?
UDT
UDTUDT
UDT
xlight
?
sector-sphere
sector-spheresector-sphere
sector-sphere
xlight
?
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
xlight
?
Gfarm Fs Tatebe Tip2004
Gfarm Fs Tatebe Tip2004Gfarm Fs Tatebe Tip2004
Gfarm Fs Tatebe Tip2004
xlight
?
Make Your web Work
Make Your web WorkMake Your web Work
Make Your web Work
xlight
?
Capacity Management from Flickr
Capacity Management from FlickrCapacity Management from Flickr
Capacity Management from Flickr
xlight
?
openid-pres
openid-presopenid-pres
openid-pres
xlight
?
淘宝无线电子商务数据报告
淘宝无线电子商务数据报告淘宝无线电子商务数据报告
淘宝无线电子商务数据报告
xlight
?
New zealand bloom filter
New zealand bloom filterNew zealand bloom filter
New zealand bloom filter
xlight
?
Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0
xlight
?
Oracle ha
Oracle haOracle ha
Oracle ha
xlight
?
Oracle 高可用概述
Oracle 高可用概述Oracle 高可用概述
Oracle 高可用概述
xlight
?
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
xlight
?
颁/颁++与尝耻补混合编程
颁/颁++与尝耻补混合编程颁/颁++与尝耻补混合编程
颁/颁++与尝耻补混合编程
xlight
?
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed SystemsGoogle: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
xlight
?
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed SystemsGoogle: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
xlight
?
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile ServiceHigh Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
xlight
?
PgSQL vs MySQL
PgSQL vs MySQLPgSQL vs MySQL
PgSQL vs MySQL
xlight
?
SpeedGeeks
SpeedGeeksSpeedGeeks
SpeedGeeks
xlight
?
GOOGLE: Designs, Lessons and Advice from Building Large Distributed Systems
GOOGLE: Designs, Lessons and Advice from Building Large   Distributed Systems GOOGLE: Designs, Lessons and Advice from Building Large   Distributed Systems
GOOGLE: Designs, Lessons and Advice from Building Large Distributed Systems
xlight
?
sector-sphere
sector-spheresector-sphere
sector-sphere
xlight
?
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
xlight
?
Gfarm Fs Tatebe Tip2004
Gfarm Fs Tatebe Tip2004Gfarm Fs Tatebe Tip2004
Gfarm Fs Tatebe Tip2004
xlight
?
Make Your web Work
Make Your web WorkMake Your web Work
Make Your web Work
xlight
?
Capacity Management from Flickr
Capacity Management from FlickrCapacity Management from Flickr
Capacity Management from Flickr
xlight
?
openid-pres
openid-presopenid-pres
openid-pres
xlight
?

Stats partitioned table

  • 2. About ACOUG ? ACOUG: All China Oracle User Group ? http://acoug.org
  • 3. About Me ? Kamus 张乐奕 ? http://www.dbform.com ? PCCW -> Oracle -> Enmou ? 将技术作为艺术对待 ? 以兴奋的状态面对知识
  • 4. 来源 ? Doug Burns ? http://oracledoug.com/ ? Statistics on Partitioned Tables
  • 5. Global Statistics ? 以默认方式收集统计信息 exec dbms_stats.gather_table_stats('KAMUS', 'TAB_PART', GRANULARITY => 'DEFAULT'); ? What is Default ? granularity => ' DEFAULT ' = 'GLOBAL AND PARTITION' ? 包括表,分区的全体统计信息,但是不包括子分区 ? Oracle10gR2 ,Oracle11gR1/R2 ? granularity => ' AUTO' ? 按照分区类型决定,可能包括表,分区,子分区的所 有全体统计信息
  • 6. Aggregated Statistics ? 只收集子分区的统计信息 exec dbms_stats.delete_table_stats('KAMUS', 'TAB_PART'); exec dbms_stats.gather_table_stats('KAMUS','TAB_PART', GRANULARITY => 'SUBPARTITION'); ? 聚合统计信息 ? 减少统计信息生成时的系统开销
  • 7. 坏的情况 ? 新加载数据 ? 收集有数据变化的子分区统计信息 exec dbms_stats.gather_table_stats('KAMUS','TAB_PART', GRANULARITY => 'SUBPARTITION', PARTNAME => 'P_20100206_GROT'); ? 聚合统计信息正确 ? 列上的统计信息呢?NDV ? 在11gR2中得以改善 (Not Tested): APPROX_GLOBAL AND PARTITION
  • 8. 还有坏的情况 ? 增加子分区 ALTER TABLE TAB_PART ADD PARTITION P_20100208 VALUES LESS THAN (20100209); ? 新加载数据 ? 收集有数据变化的某个子分区统计信息 exec dbms_stats.gather_table_stats('KAMUS','TAB_PART', GRANULARITY => 'SUBPARTITION', PARTNAME => 'P_20100208_GROT'); ? 聚合统计信息? ? 在每次收集子分区统计信息时都会聚合 ? 在删除子分区统计信息时不会发生聚合
  • 9. 还有更坏的情况 ? 新创建的分区表没有任何数据 ? 收集分区统计信息 exec dbms_stats.gather_table_stats('KAMUS','TAB_PART', GRANULARITY => 'PARTITION'); ? 新加载数据 ? 聚合? ? 收集子分区的统计信息? ? 收集全部子分区的统计信息?
  • 10. WHY ? 真实全局统计信息 VS. 聚合全局统计信息 ? 真实 WIN!
  • 11. Conclusion ? 知道我们在做什么再去做! ? 如果只选择收集SUBPARTITION统计信息, 那么要确认聚合统计信息会正确生成。
  • 12.