Stats partitioned table
-
Upload
xlight -
Category
Technology
-
view
107 -
download
5
description
Transcript of Stats partitioned table
分区表与统计信息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统计信息,那么要确认聚合统计信息会正确生成。
问 答