• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Vldb Statistics Gathering Strategy
 

Vldb Statistics Gathering Strategy

on

  • 4,101 views

How to gather histogram in Oracle database, how to gather partitioned table statistics.

How to gather histogram in Oracle database, how to gather partitioned table statistics.

Statistics

Views

Total Views
4,101
Views on SlideShare
1,368
Embed Views
2,733

Actions

Likes
0
Downloads
27
Comments
0

9 Embeds 2,733

http://www.dbform.com 2652
http://www.zhuaxia.com 35
http://www.freedba.net 20
http://cache.baidu.com 14
http://xianguo.com 6
http://zhuaxia.com 3
http://snapshot.soso.com 1
http://www.dbform.com&_=1327888408094 HTTP 1
http://feeds.feedburner.com 1
More...

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • granularity Granularity of statistics to collect (only pertinent if the table is partitioned).'ALL' - gathers all (subpartition, partition, and global) statistics'AUTO'- determines the granularity based on the partitioning type. This is the default value.'DEFAULT' - gathers global and partition-level statistics. This option is obsolete, and while currently supported, it is included in the documentation for legacy reasons only. You should use the 'GLOBAL AND PARTITION' for this functionality. Note that the default value is now 'AUTO'.'GLOBAL' - gathers global statistics'GLOBAL AND PARTITION' - gathers the global and partition level statistics. No subpartition level statistics are gathered even if it is a composite partitioned object.'PARTITION '- gathers partition-level statistics'SUBPARTITION' - gathers subpartition-level statistics.

Vldb Statistics Gathering Strategy Vldb Statistics Gathering Strategy Presentation Transcript

  • VLDB Statistics Gathering StrategySomething You Need to Know But Maybe You Don’t
  • About Me • Technical Director @ Enmo Tech • ACOUG Co-founder, President • Interests: – My wife and my son – Database technology (all related) – World of Warcraft (online game) • http://www.enmotech.com • http://www.acoug.org • http://www.dbform.com云和恩墨 成就所托
  • Statistics Gathering• Manually – dbms_stats.gather_table_stats• Automatically – 10g: DBMS_SCHEDULER – 11g: DBMS_AUTO_TASK_ADMIN云和恩墨 成就所托
  • What is Histogram1210 8 Value 1 Value 2 6 Value 3 4 Value 4 Value 5 2 0 Column 1 Column 2 Column 3 Column 4云和恩墨 成就所托
  • What is Histogram• frequency 800 700 700 600 500 500 Distinct Value 1 400 Distinct Value 2 400 Distinct Value 3 300 200 Distinct Value 4 200 Distinct Value 5 100 100 0 Records#云和恩墨 成就所托
  • What is Histogram• height balanced 120 1 2 3 4 5 5 5 6 7 8 Bucket 1 100 Bucket 2 80 Bucket 3 Bucket 4 60 Bucket 5 Bucket 6 40 Bucket 7 20 Bucket 8 Bucket 9 0 Bucket 10 Records#云和恩墨 成就所托
  • When We DON’T Need Histogram?• 此列不用于查询• 列值分布平均• 不需要多个执行计划云和恩墨 成就所托
  • Histogram Impact COST!!云和恩墨 成就所托
  • How Many Choices dba_tab_modific• method_opt=> ations – for columns size skewonly [column_name] – for columns size auto [column_name] COL_USAGE$ – for columns size repeat [column_name] – for columns size 1 [column_name] – for all columns – for all indexed columns云和恩墨 成就所托
  • How Should We Do?• Step 1 – method_opt=>FOR ALL COLUMNS SIZE 1• Step 2 (repeat) – method_opt=>FOR COLUMNS SIZE AUTO [COLUMN_NAME]• Step 3 – Using atomatic statistics gathering job – (10g) exec DBMS_STATS.SET_PARAM (METHOD_OPT, FOR ALL COLUMNS SIZE REPEAT); – (11g) exec DBMS_STATS.SET_GLOBAL_PREFS(METHOD_OPT,FOR ALL COLUMNS SIZE REPEAT);云和恩墨 成就所托
  • What is Granularity• 只针对分区表• ALL• AUTO (默认值)• DEFAULT = GLOBAL AND PARTITION• GLOBAL• GLOBAL AND PARTITION• PARTITION• SUBPARTITION云和恩墨 成就所托
  • Global Statistics• 收集统计信息 exec dbms_stats.gather_table_stats(KAMUS, TAB_PART’);• 聚合统计信息 – 降低开销 exec dbms_stats.gather_table_stats(‘KAMUS’, ‘TAB_PART’, GRANU LARITY => SUBPARTITION); TAB_PART表,20万记录 收集统计信息:Consistent Read = 23432 聚合统计信息:Consistent Read = 12036云和恩墨 成就所托
  • 坏的情况• 新加载数据• 收集有数据变化的子分区统计信息 exec dbms_stats.gather_table_stats(KAMUS,TAB_PART, GRANU LARITY => SUBPARTITION, PARTNAME => P_20111206_BEIJING);• 聚合统计信息正确• 列统计信息呢?NDV云和恩墨 成就所托
  • 还有坏的情况• 增加子分区 ALTER TABLE TAB_PART ADD PARTITION P_20111208 VALUES LESS THAN (20111209);• 新加载数据• 收集有数据变化的子分区统计信息 exec dbms_stats.gather_table_stats(KAMUS,TAB_PART, GRANULAR ITY => SUBPARTITION, PARTNAME => P_20111208_BEIJING);• 聚合统计信息呢?• 列统计信息呢?云和恩墨 成就所托
  • 还有更坏的情况• 新创建的分区表没有任何数据• 收集分区统计信息 exec dbms_stats.gather_table_stats(KAMUS,TAB_PART’);• 新加载数据• 聚合? • 收集子分区的统计信息? • 收集全部子分区的统计信息? • 收集全部分区的统计信息?云和恩墨 成就所托
  • Conclusion• 如果只选择收集SUBPARTITION统计信息,那么要 确认聚合统计信息会正确生成。云和恩墨 成就所托
  • 问 答云和恩墨 成就所托