SlideShare a Scribd company logo
1 of 12
Download to read offline
分区表与统计信息
 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

Oracle中比对2张表之间数据是否一致的几种方法
Oracle中比对2张表之间数据是否一致的几种方法Oracle中比对2张表之间数据是否一致的几种方法
Oracle中比对2张表之间数据是否一致的几种方法maclean liu
 
自下而上的数据仓库构建方法
自下而上的数据仓库构建方法自下而上的数据仓库构建方法
自下而上的数据仓库构建方法tongxiaojun
 
oracle优化器星型转换
oracle优化器星型转换oracle优化器星型转换
oracle优化器星型转换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 databoxu42
 
杰表.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 systemted-xu
 
数据库性能诊断的七种武器
数据库性能诊断的七种武器数据库性能诊断的七种武器
数据库性能诊断的七种武器Leyi (Kamus) Zhang
 
Something about oracle joins
Something about oracle joinsSomething about oracle joins
Something about oracle joinsmysqlops
 
Catia v5 CAM enhancement
Catia v5 CAM enhancementCatia v5 CAM enhancement
Catia v5 CAM enhancementJimmy Chang
 
MySQL資料表正規化草稿
MySQL資料表正規化草稿MySQL資料表正規化草稿
MySQL資料表正規化草稿jiannrong
 
MySQL 6.0 下的cluster + replicate - 20080220
MySQL 6.0 下的cluster + replicate - 20080220MySQL 6.0 下的cluster + replicate - 20080220
MySQL 6.0 下的cluster + replicate - 20080220Jinrong Ye
 

Similar to Stats partitioned table (16)

Oracle中比对2张表之间数据是否一致的几种方法
Oracle中比对2张表之间数据是否一致的几种方法Oracle中比对2张表之间数据是否一致的几种方法
Oracle中比对2张表之间数据是否一致的几种方法
 
Optimzing mysql
Optimzing mysqlOptimzing mysql
Optimzing mysql
 
自下而上的数据仓库构建方法
自下而上的数据仓库构建方法自下而上的数据仓库构建方法
自下而上的数据仓库构建方法
 
oracle优化器星型转换
oracle优化器星型转换oracle优化器星型转换
oracle优化器星型转换
 
淘宝数据魔方的系统架构 -长林
淘宝数据魔方的系统架构 -长林淘宝数据魔方的系统架构 -长林
淘宝数据魔方的系统架构 -长林
 
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
 
杰表.2008报表实例研究
杰表.2008报表实例研究杰表.2008报表实例研究
杰表.2008报表实例研究
 
分区表基础知识培训
分区表基础知识培训分区表基础知识培训
分区表基础知识培训
 
数据库原理第三章
数据库原理第三章数据库原理第三章
数据库原理第三章
 
11, OCP - awr & alert system
11, OCP - awr & alert system11, OCP - awr & alert system
11, OCP - awr & alert system
 
数据库性能诊断的七种武器
数据库性能诊断的七种武器数据库性能诊断的七种武器
数据库性能诊断的七种武器
 
Enterprise Data Lake in Action
Enterprise Data Lake in ActionEnterprise Data Lake in Action
Enterprise Data Lake in Action
 
Something about oracle joins
Something about oracle joinsSomething about oracle joins
Something about oracle joins
 
Catia v5 CAM enhancement
Catia v5 CAM enhancementCatia v5 CAM enhancement
Catia v5 CAM enhancement
 
MySQL資料表正規化草稿
MySQL資料表正規化草稿MySQL資料表正規化草稿
MySQL資料表正規化草稿
 
MySQL 6.0 下的cluster + replicate - 20080220
MySQL 6.0 下的cluster + replicate - 20080220MySQL 6.0 下的cluster + replicate - 20080220
MySQL 6.0 下的cluster + replicate - 20080220
 

More from xlight

淘宝无线电子商务数据报告
淘宝无线电子商务数据报告淘宝无线电子商务数据报告
淘宝无线电子商务数据报告xlight
 
New zealand bloom filter
New zealand bloom filterNew zealand bloom filter
New zealand bloom filterxlight
 
Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0xlight
 
Oracle ha
Oracle haOracle ha
Oracle haxlight
 
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 Feb2010xlight
 
C/C++与Lua混合编程
C/C++与Lua混合编程C/C++与Lua混合编程
C/C++与Lua混合编程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 Systemsxlight
 
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 Systemsxlight
 
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 Servicexlight
 
PgSQL vs MySQL
PgSQL vs MySQLPgSQL vs MySQL
PgSQL vs MySQLxlight
 
SpeedGeeks
SpeedGeeksSpeedGeeks
SpeedGeeksxlight
 
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-spherexlight
 
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 Tip2004xlight
 
Make Your web Work
Make Your web WorkMake Your web Work
Make Your web Workxlight
 
Capacity Management from Flickr
Capacity Management from FlickrCapacity Management from Flickr
Capacity Management from Flickrxlight
 
openid-pres
openid-presopenid-pres
openid-presxlight
 

More from xlight (20)

淘宝无线电子商务数据报告
淘宝无线电子商务数据报告淘宝无线电子商务数据报告
淘宝无线电子商务数据报告
 
New zealand bloom filter
New zealand bloom filterNew zealand bloom filter
New zealand bloom filter
 
Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0
 
Oracle ha
Oracle haOracle ha
Oracle ha
 
Oracle 高可用概述
Oracle 高可用概述Oracle 高可用概述
Oracle 高可用概述
 
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
 
C/C++与Lua混合编程
C/C++与Lua混合编程C/C++与Lua混合编程
C/C++与Lua混合编程
 
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
 
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
 
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
 
PgSQL vs MySQL
PgSQL vs MySQLPgSQL vs MySQL
PgSQL vs MySQL
 
SpeedGeeks
SpeedGeeksSpeedGeeks
SpeedGeeks
 
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
 
UDT
UDTUDT
UDT
 
sector-sphere
sector-spheresector-sphere
sector-sphere
 
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 ...
 
Gfarm Fs Tatebe Tip2004
Gfarm Fs Tatebe Tip2004Gfarm Fs Tatebe Tip2004
Gfarm Fs Tatebe Tip2004
 
Make Your web Work
Make Your web WorkMake Your web Work
Make Your web Work
 
Capacity Management from Flickr
Capacity Management from FlickrCapacity Management from Flickr
Capacity Management from Flickr
 
openid-pres
openid-presopenid-pres
openid-pres
 

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.