您的位置:首页 > 运维架构

[bbk2344] 第49集 - Chapter 12-Optimizing Sore Perations(04)

2013-05-07 17:52 1086 查看

Generating Histograms

Histogram statistics are generated by:

SQL>EXECUTE dbms_stats.gather_table_stats('HR','EMPLOYEES',METHOD_OPT => 'FOR COLUMNS SIZE 10 salary') ;


Histograms are specified using the METHOD_OPT argument of the DBMS_STATS gathering procedure.Oracle recommends setting the MEHTHOD_OPT to FOR ALL COLUMNS SIZE AUTO.Wtih this setting,Oracle automatically determines which columns require histograms and the number of buckets(size) of each histogram.You can also manually specify which columns should have histograms and the size of each histogram.

生成直方图

SQL> SELECT endpoint_number,endpoint_value FROM dba_histograms WHERE owner='HR' and table_name = 'T' AND column_name = 'ID';

ENDPOINT_NUMBER ENDPOINT_VALUE
--------------- --------------
0              1
1             10
2             20
3             30
4             40
5             50
6             60
7             70
8             80
9             90
10            100

11 rows selected.


Gather Statistics Estimates

dbms_stats.auto_samp[le_size:

New estimate_percent value

MEHTOD_OPT options:

-REPEAT:New histogram with same number of buckets

-AUTO:Net histogram based on data distribution and application workload

-SKEWONLY:New histogram based on data distribution

SQL>EXECUTE dbms_status.gather_schema_stats(ownname => 'OE',estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,method_opt => 'for all columns size AUTO');


Auto Statistics Collecting

For the dbms_status.gather_schema_stats procedure set OPTIONS to:

Gather stale

Gather Empty

Gather Auto

SQL>EXEC dbms_stats.gather_schema_stats(OWNNAME => 'OE',OPTIONS => 'GATHER AUTO');


如何让一张表处于被监控状态?

alter table hr.t monitoring;

Statistics分为四大类

Table

Index

Column

System

Optimizer Cost Model

Three columns in plan_table are:

-cpu_cost:Estimated CPU cost of the operation

-io_cost:Estimated I/O cost of the operation

-temp_space:Estimated temporary space(in bytes)

Include CPU usage

Accounts for the effect of caching

Accounts for index prefetching
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: