2.1.1.2_3 Oracle SYS.DBMS_STATS 传入参数整理


相关链接



相关链接


非常用参数

D=Default

Ser
序号
Parameter
参数名称
DIN / OUTCntNote
参数说明
Range
取值范围
1avgclen
NUMBER
YIN1Average length for the column (in bytes)
列的平均长度(以字节为单位)
DBMS_STATS.set_column_stats
NULLdefault
[Any Number]
2avgclen
NUMBER
OUT1Average length for the column (in bytes)
列的平均长度(以字节为单位)
3avgdblk
NUMBER
YIN1Average integral number of data blocks in the table pointed to by a distinct key for this index (partition). If not provided, then this value is derived from clstfct and numdist.
表中由索引(分区)的键distinct后所指向的数据块的平均整数数。如果没有提供,则该值来自clstfctnumdist
DBMS_STATS.set_index_stats
NULLdefault
4avgdblk
NUMBER
OUT1Average integral number of data blocks in the table pointed to by a distinct key for this index (partition).
表中由索引(分区)的键distinct后所指向的数据块的平均整数数。
DBMS_STATS.get_index_stats
5avglblk
NUMBER
YIN1Average integral number of data blocks in the table pointed to by a distinct key for this index (partition). If not provided, then this value is derived from clstfct and numdist.
表中由索引(分区)的键distinct后所指向的数据块的平均整数数。如果没有提供,则该值来自clstfctnumdist
DBMS_STATS.set_index_stats
NULLdefault
6avglblk
NUMBER
OUT3Average integral number of data blocks in the table pointed to by a distinct key for this index (partition).
表中由索引(分区)的键distinct后所指向的数据块的平均整数数。
DBMS_STATS.get_index_stats
7avgrlen
NUMBER
YIN1Average row length for the table (partition)
表(分区)的平均行长度(没有指明但应该是字节长度)
DBMS_STATS.set_table_stats
NULLdefault
8before_timestamp
TIME STAMP
WITH
TIME ZONE
YIN1Versions of statistics saved before this timestamp are purged. If NULL, it uses the purging policy used by automatic purge. The automatic purge deletes all history older than the older of (current time - statistics history retention) and (time of recent analyze in the system - 1). The statistics history retention value can be changed using ALTER_STATS_HISTORY_RETENTION Procedure.The default is 31 days.
在此时间戳之前保存的统计数据版本将被清除。如果为NULL,则使用自动清除所使用的清除策略。自动清除会删除比( sysdate - 统计历史保留)和(最近分析时间 - 1)更早的所有历史,可以用 ALTER_STATS_HISTORY_RETENTION 过程更改统计历史保留值。
默认值为31天。

DBMS_STATS.PURGE_STATS
[sysdate-31]default
  默认值。
NULL
   自动清除策略,见左侧。
[Any Date]
   该时间戳之前的统计数据将被清除。
9cascade_columns
BOOLEAN
YIN1Indicates that DELETE_COLUMN_STATS should be called for all underlying columns (passing the cascade_parts parameter)
表示应该为下面所有的列调用 DELETE_COLUMN_STATS 过程(传递 cascade_parts 参数)
DBMS_STATS.delete_table_stats
TRUEdefault
FALSE
10cascade_indexes
BOOLEAN
YIN1Indicates that DELETE_INDEX_STATS should be called for all underlying indexes (passing the cascade_parts parameter)
表示应该为下面所有的索引调用 DELETE_COLUMN_STATS 过程(传递 cascade_parts 参数)
DBMS_STATS.delete_table_stats
TRUEdefault
FALSE
11charvals
SYS.
DBMS_STATS.
CHARARRAY
IN1The array of values when the column type is character-based. Up to the first 32 bytes of each string should be provided. Arrays must have between 2 and 256 entries, inclusive. If the datatype is fixed CHAR, the strings must be space-padded to 15 characters for correct normalization.
值是字符类型的数组。参数每个字符串的前32个字节。数组必须包含2到256个条记录。如果数据类型是CHAR,则字符串必须用空格填充到15个字符。
[String Array List]
12clstfct
NUMBER
YIN1See clustering_factor column of the all_indexes view for a description
有关描述,请参见all_indexes视图的clustering_factor列
all_indexes => clustering_factor
Indicates the amount of order of the rows in the table based on the values of the index.
  ● If the value is near the number of blocks, then the table is very well ordered. In this case, the index entries in a single leaf block tend to point to rows in the same data blocks.
  ● If the value is near the number of rows, then the table is very randomly ordered. In this case, it is unlikely that index entries in the same leaf block point to rows in the same data blocks.
For bitmap indexes, this column is not applicable.
集群因子,是衡量数据在数据块中存放的好坏与整齐有序。
该数值越大(越接近行数),则表示数据大多随机排序,同一叶块的索引项不太可能指向同一数据块中的行。
该值越小(越接近块数),则表示数据排序非常好,单个叶块中索引大多指向相同数据块中的行。

DBMS_STATS.set_index_stats
NULLdefault
13clstfct
NUMBER
OUT1Clustering factor for the index (partition)
索引(分区)的集群因子
DBMS_STATS.get_index_stats
14col_stat_type
VARCHAR2
YIN1Type of column statistics to be deleted.This argument takes the following values:
要删除的列统计信息的类型。这个参数采用以下值:
 ● HISTOGRAM - delete column histogram only
 ● ALL - delete base column statistics and histogram
DBMS_STATS.delete_column_stats
HISTOGRAM
  仅删除列直方图(histogram)
ALLdefault
  删除基列统计信息和直方图(histogram)
15comp_id
VARCHAR2
YIN1Component id of the schema to analyze (NULL will result in analyzing schemas of all RDBMS components).Please refer to comp_id column of DBA_REGISTRY view. The procedure always gather statistics on ‘SYS’ and ‘SYSTEM’ schemas regardless of this argument.
要分析的方案(schema)的组件id (若指定参数为NULL将分析所有RDBMS组件下的方案)。参考DBA_REGISTRY视图中的comp_id列。不管这个参数是什么,这个过程总是收集关于"SYS"和"SYSTEM"方案(schema)的统计信息。
DBMS_STATS.gather_dictionary_stats
NULLdefault
[Component id]
16datevals
SYS.
DBMS_STATS.
DATERAY
IN1Array of values when the column type is date-based
值是日期类型的数组
[Date Array List]
17dblink
VARCHAR2
IN1Name of dblink
dblink (Database Link 数据库连接)的名称
[DBlink Name]
18dblvals
SYS.
DBMS_STATS.
DBLARRAY
IN1Array of values when the column type is double-based
值是double-based类型的数组
[Double Array List]
19density
NUMBER
OUT1Column density. If this value is NULL and if distcnt is not NULL, then density is derived from distcnt
列密度。如果 density=NULL 且 distcnt<>NULL ,那么 density = distcnt 。
NULLdefault
[Any Number]
20density
NUMBER
YIN1Column density. If this value is NULL and if distcnt is not NULL, then density is derived from distcnt
列密度。如果 density=NULL 且 distcnt<>NULL ,那么 density = distcnt 。
DBMS_STATS.set_column_stats
NULLdefault
[Any Number]
21distcnt
NUMBER
OUT1NUMBER of distinct values
不同值的个数
DBMS_STATS.get_column_stats
22distcnt
NUMBER
YIN1NUMBER of distinct values
不同值的个数
DBMS_STATS.set_column_stats
NULLdefault
[Any Number]
23dstpartname
VARCHAR2
IN1Destination [sub] partition
目标(子)分区
DBMS_STATS.copy_table_stats
24extension
VARCHAR2
IN1Can be either a column group or an expression. Suppose the specified table has two column c1, c2. An example column group can be “(c1, c2)” and an example expression can be “(c1 + c2)”.
可以是列组或表达式。假设指定的表有两列c1和c2。示例列组可以是"(c1, c2)“,示例表达式可以是”(c1 + c2)"。
DBMS_STATS.create_extended_stats
[Column Group]
  例:(c1, c2)
[An Expression]
  例:(c1 + c2)
25fltvals
SYS.
DBMS_STATS.
FLTARRAY
IN1Array of values when the column type is float-based
值是浮点类型的数组
DBMS_STATS.prepare_column_values
[Float Array List]
26guessq
NUMBER
YIN1Guess quality. See the pct_direct_access column of the all_indexes view for a description.
猜测质量。有关描述,请查看 all_indexes 视图的 pct_direct_access 列。
all_indexes => pct_direct_access
For a secondary index on an index-organized table, the percentage of rows with VALID guess
对于索引组织的表上的次要索引,猜测有效的行的百分比
DBMS_STATS.set_index_stats
NULLdefault
27guessq
NUMBER
OUT1Guess quality. See the pct_direct_access column of the all_indexes view for a description.
猜测质量。有关描述,请查看 all_indexes 视图的 pct_direct_access 列。
all_indexes => pct_direct_access
For a secondary index on an index-organized table, the percentage of rows with VALID guess
对于索引组织的表上的次要索引,猜测有效的行的百分比
DBMS_STATS.get_index_stats
28indlevel
NUMBER
YIN1Height of the index (partition)
索引(分区)的高度
DBMS_STATS.set_index_stats
NULLdefault
29indlevel
NUMBER
OUT1Height of the index (partition)
索引(分区)的高度
DBMS_STATS.get_index_stats
30interval
NUMBER
YIN1Time, in minutes, to gather statistics. This parameter applies only when gathering_mode='INTERVAL'
收集统计数据的时间(以分钟为单位)。此参数仅适用于gathering_mode=‘INTERVAL’
DBMS_STATS.gather_system_stats
NULLdefault
31nullcnt
NUMBER
OUT1NUMBER of NULLs
NULL值个数
DBMS_STATS.get_column_stats
32nullcnt
NUMBER
YIN1NUMBER of NULLs
NULL值个数
DBMS_STATS.set_column_stats
NULLdefault
33numblks
NUMBER
YIN1NUMBER of blocks the table (partition) occupies
表(分区)占用的块数
DBMS_STATS.set_table_stats
NULLdefault
34numblks
NUMBER
OUT1NUMBER of blocks the table (partition) occupies
表(分区)占用的块数
DBMS_STATS.get_table_stats
35numdist
NUMBER
OUT1NUMBER of distinct keys in the index (partition)
索引(分区)中不重复键个数
DBMS_STATS.get_index_stats
36numdist
NUMBER
YIN1NUMBER of distinct keys in the index (partition)
索引(分区)中不重复键个数
DBMS_STATS.set_index_stats
NULLdefault
37numlblks
NUMBER
YOUT1NUMBER of leaf blocks in the index (partition)
索引(分区)占用的块数
DBMS_STATS.get_index_stats
38numlblks
NUMBER
YIN1NUMBER of leaf blocks in the index (partition)
索引(分区)占用的块数
DBMS_STATS.set_index_stats
NULLdefault
39numvals
SYS.
DBMS_STATS.
NUMARRAY
IN1Array of values when the column type is numeric-based
值是数值类型的数组
DBMS_STATS.prepare_column_values
[Num Array List]
40nvmax
VARCHAR2
IN1Minimum and maximum values when the column type is national character set based. No histogram information can be provided for a column of this type. If the datatype is fixed CHAR, the strings must be space-padded to 15 characters for correct normalization.
列类型是国际字符集(National Character Set)时的最小值和最大值。不能为此类列提供直方图信息。如果数据类型为固定CHAR,则字符串必须用空格填充为15个字符以实现正确的规范化。
DBMS_STATS.prepare_column_values_nvarchar2
41nvmin
VARCHAR2
IN1Minimum and maximum values when the column type is national character set based. No histogram information can be provided for a column of this type. If the datatype is fixed CHAR, the strings must be space-padded to 15 characters for correct normalization.
列类型是国际字符集(National Character Set)时的最小值和最大值。不能为此类列提供直方图信息。如果数据类型为固定CHAR,则字符串必须用空格填充为15个字符以实现正确的规范化。
DBMS_STATS.prepare_column_values_nvarchar2
42objname
VARCHAR2
IN1Name of object
对象的名称
DBMS_STATS.generate_stats
[Any Object]
43organized
NUMBER
YIN1Amount of ordering associated between the index and its underlying table. A heavily organized index would have consecutive index keys referring to consecutive rows on disk for the table (the same block). A heavily disorganized index would have consecutive keys referencing different table blocks on disk.
This parameter is only used for b-tree indexes. The number can be in the range of 0-10, with 0 representing a completely organized index and 10 a completely disorganized one.
  索引与其基础表排序相关性。一个有序的索引应使用连续的索引键来引用表(相同的块)磁盘上的连续行。一个无序的索引会有连续的键来引用磁盘上不同的表块。
  此参数仅用于b-树索引。数字的范围可以是0-10,其中0表示一个完全组织好的索引,10表示一个完全没有组织的索引。

DBMS_STATS.generate_stats
7default
[1-10]
44owner_name
VARCHAR2
IN1Owner of the SQL tuning set.
SQL优化集的所有者
DBMS_STATS.seed_col_usage
45rawvals
SYS.
DBMS_STATS.
RAWARRAY
IN1Array of values when the column type is RAW. Up to the first 32 bytes of each strings should be provided.
值是RAW类型的数组。参数值为每个字符串的的前32个字节。
DBMS_STATS.prepare_column_values
[RAW Array List]
46restore_cluster_index
BOOLEAN
YIN1If the table is part of a cluster, restore statistics of the cluster index if set to TRUE
如果表是集群的一部分,设置为TRUE,则恢复集群索引的统计信息
DBMS_STATS.restore_table_stats

TRUE
FALSEdefault
47resval
BIANARY_DOUBLE
OUT1The converted, type-specific value
转换后的特定类型的值
DBMS_STATS.convert_raw_value
48resval
BINARY_FLOAT
OUT1The converted, type-specific value
转换后的特定类型的值
DBMS_STATS.convert_raw_value
49resval
DATE
OUT1The converted, type-specific value
转换后的特定类型的值
DBMS_STATS.convert_raw_value
50resval
NUMBER
OUT1The converted, type-specific value
转换后的特定类型的值
DBMS_STATS.convert_raw_value
51resval
NVARCHAR2
OUT1The converted, type-specific value
转换后的特定类型的值
DBMS_STATS.convert_raw_value_nvarchar
52resval
ROWID
OUT1The converted, type-specific value
转换后的特定类型的值
DBMS_STATS.convert_raw_value_rowid
53resval
VARCHAR2
OUT1The converted, type-specific value
转换后的特定类型的值
DBMS_STATS.convert_raw_value
54retention
NUMBER
IN1The retention time in days. The statistics history will be retained for at least these many number of days.The valid range is [1,365000]. Also you can use the following values for special purposes:
统计历史将被保留参数指定的天数。有效范围为[1,365000]。也可以指定为以下特殊值:
  ● -1 :Statistics history is never purged by automatic purge
  ● 0 : Old statistics are never saved. The automatic purge will delete all statistics history
  ● NULL : Change statistics history retention to default value
-1
  统计历史从不被自动清除。
0
  不保存旧的统计信息。自动清除所有统计历史。
NULL
  将保留天数更改为默认值。
[1,365000]
  保留统计历史的天数。
55rwmax
ROWID
IN1Minimum and maximum values when the column type is rowid. No histogram information is provided for a column of this type.
列类型为rowid时的最小值和最大值。不提供此类列的直方图信息。
DBMS_STATS.prepare_column_values_rowid
56rwmin
ROWID
IN1Minimum and maximum values when the column type is rowid. No histogram information is provided for a column of this type.
列类型为rowid时的最小值和最大值。不提供此类列的直方图信息。
DBMS_STATS.prepare_column_values_rowid
57scale_factor
NUMBER
YIN1Scale factor to scale nblks, nrows etc. in dstpartname
比例因子。在dstpartname中缩放nblks、nrows等参数
DBMS_STATS.copy_table_stats
1default
58sqlset_name
VARCHAR2
IN1Name of the SQL tuning set
SQL调优集的名称
DBMS_STATS.seed_col_usage
[SQL tuning set]
59srcpartname
VARCHAR2
IN1Source [sub] partition
源(子)分区
DBMS_STATS.copy_table_stats
60tblspace
VARCHAR2
YIN1Tablespace in which to create the statistics tables. If none is specified, then they are created in the user’s default tablespace.
创建统计信息表的表空间。如果不指定,则在用户的默认表空间中创建它们。
DBMS_STATS.create_stat_table
NULLdefault
[Statistics Tables]
61time_limit
BINARY_INTEGER
YIN1Time limit (in seconds)
时间限制(秒)
DBMS_STATS.seed_col_usage
NULLdefault
62avgrlen
NUMBER
OUT1Average row length for the table (partition)
表(分区)的平均行长度(没有指明但应该是字节长度)
DBMS_STATS.get_table_stats
63cachedblk
NUMBER
YIN2The average number of blocks in the buffer cache for the segment (index/table/index partition/table partition)
该段(索引/表/索引分区/表分区)的缓冲区缓存中的平均块数
DBMS_STATS.set_index_stats
DBMS_STATS.set_table_stats
NULLdefault
64cachedblk
NUMBER
OUT2The average number of blocks in the buffer cache for the segment (index/table/index partition/table partition)
该段(索引/表/索引分区/表分区)的缓冲区缓存中的平均块数
DBMS_STATS.get_index_stats
DBMS_STATS.get_table_stats
65ext_stats
RAW
IN2User-defined statistics
用户定义的数据
DBMS_STATS.set_column_stats
DBMS_STATS.set_index_stats
NULLdefault
66ext_stats
RAW
OUT2User-defined statistics
用户定义的数据
DBMS_STATS.get_column_stats
DBMS_STATS.get_index_stats
NULLdefault
67gather_sys
BOOLEAN
YIN2Gathers statistics on the objects owned by the ‘SYS’ user
收集关于"SYS"用户所拥有对象的统计信息
DBMS_STATS.gather_database_stats
TUREdefault
FALSE
68gathering_mode
VARCHAR2
Oracle性能分析11:系统统计信息
YIN2Mode values are:
- NOWORKLOAD : Will capture characteristics of the I/O system. Gathering may take a few minutes and depends on the size of the database. During this period Oracle will estimate the average read seek time and transfer speed for the I/O system. This mode is suitable for the all workloads. Oracle recommends to run GATHER_SYSTEM_STATS (‘noworkload’) after creation of the database and tablespaces. To fine tune system statistics for the workload use ‘START’ and ‘STOP’ or ‘INTERVAL’ options. If you gather both ‘NOWORKLOAD’ and workload specific (statistics collected using ‘INTERVAL’ or ‘START’ and ‘STOP’ ), the workload statistics will be used by optimizer. Collected components: cpuspeednw, ioseektim, iotfrspeed.
- INTERVAL : Captures system activity during a specified interval. This works in combination with the interval parameter. You should provide an interval value in minutes, after which system statistics are created or updated in the dictionary or stattab. You can use GATHER_SYSTEM_STATS (gathering_mode=>‘STOP’) to stop gathering earlier than scheduled. Collected components: maxthr, slavethr, cpuspeed, sreadtim, mreadtim, mbrc.
- START | STOP : Captures system activity during specified start and stop times and refreshes the dictionary or stattab with statistics for the elapsed period. Interval value is ignored. Collected components: maxthr, slavethr, cpuspeed, sreadtim, mreadtim, mbrc.
DBMS_STATS.gather_system_stats
非工作量统计信息
NOWORKLOADdefault
  从Oracle 10g開始,总是提供默认的非工作量统计信息,假设显式地删除,下次数据库启动时会自己主动收集。收集非工作量统计信息要在空暇的系统上进行,使用以下语句:
--------
begin
dbms_stats.gather_system_stats(gathering_mode => ‘noworkload’);
end;
--------

工作量统计信息
START | STOP
  收集工作量统计信息,不能使用空暇的系统,以为数据库引擎要利用正常的数据库负载来评估I/O子系统的性能。
  工作量统计信息的收集包括以下的步骤:
  1)运行快照并存储各种性能指标的初始值到数据字典表aux_stats$(列SNAME设定为SYSSTATS_TEMP)。使用以下的方式来启动:
--------
begin
dbms_stats.gather_system_stats(gathering_mode => ‘start’);
end;
--------
  2)等待足够的时间产生一个有代表性的负载时候再进行还有一次快照,等待时间通常不少于30分钟;
  3)进行第二次快照,使用以下的语句:
--------
begin
dbms_stats.gather_system_stats(gathering_mode => ‘stop’);
end;
--------
  4)Oracle依据两次快照之间的差值,计算出系统统计信息,假设无法计算的话,将被设置为空。
INTERVAL
  你也能够指定gathering_mode为interval,并指定间隔时间来收集工作量统计时间,这样就不用手工停止快照,以下的命令指定30分钟后进行第二次快照:
--------
begin
dbms_stats.gather_system_stats(gathering_mode => ‘interval’);
end;
--------
  须要注意上面的语句并不会延续30分钟,它仅仅是启动一个作业调度后返回。
69numrows
NUMBER
YIN2Number of rows in the index (partition)
索引(分区)中的行数
DBMS_STATS.set_index_stats
DBMS_STATS.set_table_stats
NULLdefault
[Any Number]
70numrows
NUMBER
OUT2Number of rows in the index (partition)
索引(分区)中的行数
DBMS_STATS.get_index_stats
DBMS_STATS.get_table_stats
71cascade_parts
BOOLEAN
YIN3If the table is partitioned and if partname is NULL, then setting this to TRUE causes the deletion of statistics for this table for all underlying partitions as well
如果表是分区的,参数 partname = NULL,且参数 cascade_parts = TRUE , 则删除该表所有基础分区的统计信息
DBMS_STATS.delete_column_stats
DBMS_STATS.delete_index_stats
DBMS_STATS.delete_table_stats
TRUEdefault
FALSE
72cachehit
cache(缓存)浅析
NUMBER
YIN3The average cache hit ratio for the segment (index/table/index partition/table partition)
该段(索引/表/索引分区/表分区)的平均缓存命中率
DBMS_STATS.set_index_stats
DBMS_STATS.set_table_stats
NULLdefault
73cachehit
cache(缓存)浅析
NUMBER
OUT3The average cache hit ratio for the segment (index/table/index partition/table partition)
该段(索引/表/索引分区/表分区)的平均缓存命中率
DBMS_STATS.set_index_stats
DBMS_STATS.set_table_stats
74flags
NUMBER
YIN3For internal Oracle use (should be left as NULL)
用于内部Oracle使用(应保留为NULL)
DBMS_STATS.copy_table_stats
DBMS_STATS.set_column_stats
DBMS_STATS.set_index_stats
DBMS_STATS.set_table_stats
NULLdefault
75objlist
SYS.
DBMS_STATS.
OBJECTTAB
YOUT3List of objects found to be stale or empty
发现已过时或为空的对象的列表
DBMS_STATS.gather_database_stats
DBMS_STATS.gather_dictionary_stats
DBMS_STATS.gather_schema_stats
76add_sys
BOOLEAN
YIN4Value TRUE will include the Oracle-owned tables
参数 add_sys = TRUE 则包括oracle拥有的表
DBMS_STATS.DELETE_DATABASE_PREFS
DBMS_STATS.EXPORT_DATABASE_PREFS
DBMS_STATS.IMPORT_DATABASE_PREFS
DBMS_STATS.SET_DATABASE_PREFS
TRUE
FALSEdefault

常用参数

Ser
序号| Parameter + type
参数名称 + 类型| D| IN / OUT | Cnt| Note
参数说明 | Range
取值范围
:-------- |:-------- | :-----| :-----| :-----| :-----| :-----| :-----| :-----
|77|pvalue
VARCHAR2||IN|5|Preference value. If NULL is specified, it will set the Oracle default value.s
偏好值。NULL表示Oracle默认值。|
|78|pvalue
NUMBER||OUT|1|Parameter value to get
要获取的参数值。|
|79|as_of_timestamp
TIME STAMP WITH
TIME ZONE||IN|6|The timestamp to which to restore statistics
恢复统计信息的时间戳。|
|80|obj_filter_list
SYS.
DBMS_STATS.
OBJECTTAB|Y|IN|6|A list of object filters. When provided, GATHER_DATABASE_STATS will gather statistics only on objects which satisfy at least one object filter in the list as needed. In a single object filter, we can specify the constraints on the object attributes. The attribute values specified in the object filter are case- insensitive unless double-quoted. Wildcard is allowed in the attribute values. Suppose non-NULL values s1, s2, … are specified for attributes a1, a2, … in one object filter. An object o is said to satisfy this object filter if (o.a1 like s1) and (o.a2 like s2) and … is true. See Applying an Object Filter List.
对统计对象进行筛选
√ 可以有多个条件,最终收集的对象至少满足其中一个条件
√ 单个过滤可以指定对象属性上的约束
√ 指定的的属性只不区分大小写,除非双引号
√ 属性值中允许使用通配符
DBMS_STATS.gather_database_stats | 具体使用语法见DBMS_STATS.gather_schema_stats
附录1 Applying an Object Filter List
|81|options
VARCHAR2|Y|IN|6|Further specification of which objects to gather statistics for:
- GATHER: Gathers statistics on all objects in the schema.
- GATHER AUTO: Gathers all necessary statistics automatically. Oracle implicitly determines which objects need new statistics, and determines how to gather those statistics. When GATHER AUTO is specified, the only additional valid parameters are stattab, statid, objlist and statown; all other parameter settings are ignored. Returns a list of processed objects.
- GATHER STALE: Gathers statistics on stale objects as determined by looking at the *_tab_modifications views. Also, return a list of objects found to be stale.
- GATHER EMPTY: Gathers statistics on objects which currently have no statistics. Return a list of objects found to have no statistics.
- LIST AUTO: Returns a list of objects to be processed with GATHER AUTO
- LIST STALE: Returns a list of stale objects as determined by looking at the _tab_modifications views
- LIST EMPTY: Returns a list of objects which currently have no statistics
DBMS_STATS.gather_schema_stats| GATHERdefault
  收集方案下(schema)所有对象的统计信息。
GATHER AUTO
   由Oracle自动决定收集哪些必要的统计数据。当指定参数为GATHER AUTO时,附加有效参数只有stattab, statid, objliststatown;所有其他参数设置将被忽略。返回已处理对象的列表。
GATHER STALE
   收集通过查看
_tab_modify视图确定的陈旧对象的统计信息。返回值为已过期对象的列表。
GATHER EMPTY
   收集当前没有统计信息的对象的统计信息。返回没有统计信息对象的列表。
LIST AUTO
   返回要用 GATHER AUTO 处理对象的列表。
LIST STALE
   返回要用 GATHER STALE 处理对象的列表。
LIST EMPTY
   返回要用 GATHER EMPTY 处理对象的列表。

┄┄┄注意,无论gather stale还是gather auto,都要求进行监视。如果你执行一个alter table xxx monitoring命令,Oracle会用dba_tab_modifications视图来跟踪发生变动的表。
┄┄┄这样一来,你就确切地知道,自从上一次分析统计数据以来,发生了多少次插入、更新和删除操作。
|82|block_sample
BOOLEAN|Y|IN|7|Determines whether or not to use random block sampling instead of random row sampling. Random block sampling is more efficient, but if the data is not randomly distributed on disk then the sample values may be somewhat correlated. Only pertinent when performing estimate statistics.
确定是否使用随机数据块采样代替随机行采样。随机数据块采样更快,但如果数据不是随机分布在磁盘上,那么样本值可能不准确。
《oracle的数据块》
DBMS_STATS.gather_table_stats|TRUE
FALSEdefault
|83|colname
VARCHAR2||IN|7|Name of the column or extension
列或扩展的名称
DBMS_STATS.set_column_stats|[Any column or extension]
|84|method_opt
VARCHAR2
统计量收集Method_Opt参数使用(上)
统计量收集Method_Opt参数使用(下) |Y|IN|7|Accepts:
 ● FOR ALL [INDEXED | HIDDEN] COLUMNS [size_clause]
 ● FOR COLUMNS [size clause] column [size_clause] [,column [size_clause]...]
 
size_clause is defined as size_clause := SIZE {integer | REPEAT | AUTO | SKEWONLY}

column is defined as column := column_name | extension name | extension
- integer : Number of histogram buckets. Must be in the range [1,254].
- REPEAT : Collects histograms only on the columns that already have histograms.
- AUTO : Oracle determines the columns on which to collect histograms based on data distribution and the workload of the columns.
- SKEWONLY : Oracle determines the columns on which to collect histograms based on the data distribution of the columns.
The default is FOR ALL COLUMNS SIZE AUTO.The default value can be changed using the SET_DATABASE_PREFS Procedure, SET_GLOBAL_PREFS Procedure, SET_SCHEMA_PREFS Procedure and SET_TABLE_PREFS Procedure.
决定histograms信息是怎样被统计的
√ 决定哪些columns统计被收集
√ 决定哪些columns直方图被收集以及直方图包含多少个buckets

DBMS_STATS.gather_database_stats| get_param(‘METHOD_OPT’)default
  = DEFAULT_METHOD_OPT
  = FOR ALL COLUMNS SIZE AUTO
由Oralce决定N的大小

for all columns
  统计所有列的histograms。
for all indexed columns
  统计所有有索引列的histograms。
for all hidden columns
  统计你看不到列的histograms。
for all columns SIZE 10
  所有列buckt数量为10, buck∈【1,254】
for all columns SIZE REPEAT
  上次统计过的histograms。
for all columns SIZE AUTO
  【默认】由oracle决定N的大小。
for all columns SIZE SKEWONLY
  根据数据列的分布情况来判断直方图的生成。如果数据呈现出偏移倾斜的情况,会去生成直方图。
for columns size 10 owner
  owner列的NUM_BUCKET=10
for columns size 10 owner for columns size 5 object_name
  owner列的NUM_BUCKET=10
  object_name列的NUM_BUCKET=5

for columns size 10 owner object_name object_id
  object_name 列的NUM_BUCKET=10
  object_id列的NUM_BUCKET=10

 … 
|85|rawval
RAW||IN|7|The raw representation of a column minimum or maximum datatype-specific output parameters
特定数据类型的列最小或最大输出参数的原始数据格式|
|86|degree
NUMBER|Y|IN|8|Degree of parallelism. The default for degree is NULL. The default value can be changed using the SET_DATABASE_PREFS Procedure, SET_GLOBAL_PREFS Procedure, SET_SCHEMA_PREFS Procedure and SET_TABLE_PREFS Procedure. NULL means use the table default value specified by the DEGREE clause in the CREATE TABLE or ALTER TABLE statement. Use the constant DBMS_STATS.DEFAULT_DEGREE to specify the default value based on the initialization parameters. The AUTO_DEGREE value determines the degree of parallelism automatically. This is between 1 (serial execution) and DEFAULT_DEGREE (the system default value based on number of CPUs and initialization parameters) according to the size of the object. When using DEGREE=>NULL, DEGREE=>n, or DEGREE=>DBMS_STATS.DEFAULT_DEGREE, the current implementation of DBMS_STATS may use serial execution if the size of the object does not warrant parallel execution.
决定并行度(线程数),默认值为NULL
√ 根据业务情况选择,业务闲时可设置为-1
√ 一般来说,degree值越大执行越快,如果服务器主机只有一个CPU,并行进程可能会争用CPU,从而导致实际性能可能会下降。
√ degree一般不超过10就可以了,过大会导致任务卡死,根据实际情况选择

DBMS_STATS.gather_table_stats | DBMS_STATS.
DEFAULT_DEGREE
default
  此值为默认值(取Oracle常量)。由oracle决定并行度,默认值可通过左侧介绍的四个存储过程进行修改。
  根据对象的大小,degree值介于1(串行)和DEFAULT_DEGREE(基于CPU数量和初始化参数系统默认值)之间。

NULL
  表示使用CREATE table或ALTER table语句中的DEGREE子句指定的表并行度默认值。《Oracle并行处理》
正整数
  容忍范围内,值越大运行时间越短。但值过大会抢占数据库资源,甚至任务卡死,根据实际情况选择。
|87|estimate_percent
NUMBER|Y|IN|8|Percentage of rows to estimate (NULL means compute): The valid range is [0.000001,100]. Use the constant DBMS_STATS.AUTO_SAMPLE_SIZE to have Oracle determine the appropriate sample size for good statistics. This is the default.The default value can be changed using the SET_DATABASE_PREFS Procedure, SET_GLOBAL_PREFS Procedure, SET_SCHEMA_PREFS Procedure and SET_TABLE_PREFS Procedure.
这个参数是一个百分比值,它告诉分析包需要使用表中数据的多大比例来做分析。
理论上来讲,采样的数据越多,得到的信息就越接近于实际,CBO做出的执行计划就越优化,但是,采样越多,消耗的系统资源必然越多。 对系统的影响也越大。 所以对于这个值的设置,要根据业务情况来。 如果数据的直方图分布比较均匀,就可以使用默认值:AUTO_SAMPLE_SIZE,即让Oracle 自己来判断采样的比例。有时,特别是对于批量加载的表,我们可以预估表中的数据量,可以人工地设置一个合理的值。 一般,对于一个有1000万数据的表分区,可以把这个参数设置为0.000001。
DBMS_STATS.gather_table_stats|DBMS_STATS.
AUTO_SAMPLE_SIZE
default
  默认值(取Oracle常量)。由oracle决定最佳取采样值,默认值可通过左侧介绍的四个存储过程进行修改。统计数据质量越好,CBO做出的决定越好。
  这里有一篇文章提到关于Oracle为什么不按照estimate_percent来分析表的研究。

NULL
  全部分析,不采样。

|88|granularity
VARCHAR2|Y|IN|8| 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
决定统计数据的粒度,表分区时此参数才有效,默认值为AUTO
√ 理想情况下,对表的全局,分区,子分区都做分析,这样才能得到最充足的数据;
√ 通常来讲需要分区的表数据量较大,如果每增加一个分区都需要做一次全局分析的话,会消耗极大的系统资源;但是如果只对新加入的分区进行分析而不做全局分析,Oracle 在全局范围内的信息就会不准确,导致CBO 生成错误的执行计划
DBMS_STATS.gather_table_stats| ALL
  收集统计数据范围有:全局级别(global),分区级别(partition),子分区级别(subpartition)
AUTOdefault
  根据分区类型确定粒度。这是默认值。
DEFAULT
  收集全局级别(global)和分区级别(partition)的统计信息。这个选项已经过时了,虽然目前受到支持,但仅由于遗留原因才将其包含在文档中。您应该使用GLOBAL AND PARTITION来实现此功能。注意,默认值现在是AUTO
GLOBAL
  收集全局级别(global)统计数据。
GLOBAL AND PARTITION
  收集全局级别(global)和分区级别(partition)的统计信息。即使是复合分区对象,也不会收集子分区级别(subpartition)的统计信息。
PARTITION
  收集分区级别(partition)的统计信息。
SUBPARTITION
  收集子分区级别(subpartition)的统计信息。
|89|cascade
BOOLEAN|Y|IN|9|Gathers statistics on the indexes for this table. Using this option is equivalent to running the GATHER_INDEX_STATS Pon each of the table’s indexes. Use the constant DBMS_STATS.AUTO_CASCADE to have Oracle determine whether index statistics are to be collected or not. This is the default. The default value can be changed using the SET_DATABASE_PREFS Procedure, SET_GLOBAL_PREFS Procedure, SET_SCHEMA_PREFS Procedure and SET_TABLE_PREFS Procedure.
收集索引的统计信息
√ 默认值为Oracle常量 GATHER_INDEX_STATS => 让Oalce决定
√ 此选项为 TRUE 时,相当于在表中每个索引上运行 GATHER_INDEX_STATS 存储过程
DBMS_STATS.gather_table_stats| DBMS_STATS.
AUTO_CASCADE
default
  默认值(取Oracle常量)。由oracle决定是否收集数据库中每个索引的统计信息,默认值可通过左侧介绍的四个存储过程进行修改。
TRUE
  收集索引的统计信息。
FALSE
  不收集索引的统计信息。
|90|pname
VARCHAR2||IN|9| Parameter name
索引名称。|[Any Parameter]
  不同存储过程中会有不同指定参数。
|91|indname
VARCHAR2||IN|10|Name of the index
索引名称。| [Any Index]
|92|stattype
VARCHAR2|Y|IN|17|Statistics type. The only value allowed is DATA.
数据类型。唯一允许的值是’DATA’。
DBMS_STATS.gather_table_stats| DATAdefault and only
|93|partname
VARCHAR2|Y|IN|24|Name of the table (/ index) partition in which to store the statistics.
分区的名字,只对分区表或分区索引有用。|NULLdefault
  如果为NULL,则目标为指定表的全球级别( global table level)。
[Any Partition]
|94|tabname
VARCHAR2||IN|28|Table Name
表名。|NULL
  如果为NULL,则目标为指定方案下所有表。
任意表名
|95|force
BOOLEAN|Y|IN|31|When the value of this argument is TRUE, deletes statistics of tables in a database even if they are locked
即使表锁住了也强制执行。|TRUE
FALSEdefault
|96| no_invalidate
1
BOOLEAN|Y|IN|34|Does not invalidate the dependent cursors if set to TRUE. The procedure invalidates the dependent cursors immediately if set to FALSE. Use DBMS_STATS.AUTO_INVALIDATE. to have Oracle decide when to invalidate dependent cursors. This is the default. The default can be changed using the SET_DATABASE_PREFS Procedure, SET_GLOBAL_PREFS Procedure, SET_SCHEMA_PREFS Procedure and SET_TABLE_PREFS Procedure.
DBMS_STATS.gather_table_stats|DBMS_STATS.AUTO_INVALIDATEdefault
  默认值(取Oracle常量)。让Oracle决定何时使依赖游标失效。原有的共享游标被失效,下一次在执行SQL的时候,Oracle会重新为其生成执行计划,也就是一次硬解析(Hard Parse
2)过程。
TRUE
  依赖游标有效。
FALSE
  依赖游标失效。

|97|ownname
VARCHAR2||IN|51|Name of the schema
方案(用户)的名称。|[Any Schema]
|98|ownname
VARCHAR2|Y|IN|4|Name of the schema
方案(用户)的名称。|[Current Schema]default
|99|stattypname
NUMBER||OUT|1|Name of the statistics type
统计信息类型的名称| NULLdefault
|100|stattypname
VARCHAR2||OUT|1|Name of the statistics type
统计信息类型的名称| NULLdefault
|101|stattypname
VARCHAR2|Y|IN|3|Name of the statistics type
统计信息类型的名称
DBMS_STATS.set_column_stats| NULLdefault
|102|stattypown
VARCHAR2|Y|IN|3|Schema of the statistics type
统计信息类型的方案(Schema)
DBMS_STATS.set_column_stats| NULLdefault
|103|stattypown
VARCHAR2||OUT|1|Schema of the statistics type
统计信息类型的方案(Schema)| NULLdefault
|104|stattypown
NUMBER||OUT|1|Schema of the statistics type
统计信息类型的方案(Schema)| NULLdefault
|105|statid
VARCHAR2|Y|IN|55|Identifier (optional) to associate with these statistics within stattab
statid表明stattab这个数据集的主键,可以理解为stattab的一个分区。
DBMS_STATS.gather_table_stats| NULLdefault
  不指定分区。
[Any Statid]
  指定要存储统计信息的表的分区。
|106|statown
VARCHAR2|Y|IN|55|Schema containing stattab (if different than ownname)
statown表明stattab在哪个方案下,如果statown=ownname,则可以不指定此参数。|NULLdefault
[Any Schema]
|107|stattab
VARCHAR2|Y|IN|58|User statistics table identifier describing where to store the statistics. If stattab is NULL, then the statistics are stored directly in the dictionary.
存储统计信息的目标表名。如果stattab为NULL,那么统计信息将直接存储在字典中。|NULLdefault
[Any Table]

Most of the DBMS_STATS procedures include the three parameters statown, stattab, and statid. These parameters allow you to store statistics in your own tables (outside of the dictionary), which does not affect the optimizer. Therefore, you can maintain and experiment with sets of statistics.
大多数DBMS_STATS过程包括三个参数statown、stattab和statid。这些参数允许您将统计信息存储在自己的表中(在字典之外),这不会影响优化器。因此,您可以维护和试验统计数据集。
The stattab parameter specifies the name of a table in which to hold statistics, and it is assumed that it resides in the same schema as the object for which statistics are collected (unless the statown parameter is specified). You can create multiple tables with different stattab identifiers to hold separate sets of statistics.
stattab参数指定用于保存统计信息的表的名称,并且假设它与为其收集统计信息的对象驻留在同一个方案(用户)中(除非指定了statown参数)。您可以使用不同的stattab标识符创建多个表,以保存不同的统计数据集。
The statown, stattab, and statid parameters instruct the package to back up current statistics in the specified table before gathering new statistics.
statown、stattab和statid参数指示包在收集新的统计信息之前备份指定表中的当前统计信息。


20/12/04

M


  1. no_invalidate游标是否有效(no_invalidate),它决定了新统计量生成之后,如何处理此时已经生成的执行计划,也就是在Shared Pool中的执行计划。重新生成执行计划会产生硬解析(Hard Parse),大量表同时硬解析会造成性能spike现象,影响业务运行。
     no_invalidate参数共有三种取值:DBMS_STATS.AUTO_INVALIDATETRUEFALSE;
     ● DBMS_STATS.AUTO_INVALIDATEdefault 默认策略是“延时”,已经存在shared pool中的共享游标不会一次性的失效,而是“慢慢的”、“有差别的”失效。这样的策略避免了集中hard sparse(瞬间的性能高峰期)出现,保证了系统性能平稳化过程。
      ● TRUE 表示shared pool中有依赖关系的 共享的游标(shared cursor)(执行计划)依然有效(不会被新的执行计划所失效),即使此时共享的游标已经不是最优的执行计划。
      ● FALSE 当我们收集统计量使用no_invalidate为false的时候,原有的共享游标被失效,下一次在执行SQL的时候,Oracle会重新为其生成执行计划,也就是一次 硬解析(Hard Parse) 过程。
    ↩︎

  2. Hard Parse硬解析(Hard Parse),Oralce解析SQL方式分为 硬解析(hard rase)软解析(soft prase) 当你发出一条sql语句交付Oracle,在执行和获取结果前,Oracle对此sql将进行几个步骤的处理过程:
     1、语法检查(syntax check)
       检查此sql的拼写是否语法。
     2、语义检查(semantic check)
      诸如检查sql语句中的访问对象是否存在及该用户是否具备相应的权限。
     3、对sql语句进行解析(prase)
       利用内部算法对sql进行解析,生成解析树(parse tree)及执行计划(execution plan)。
     4、执行sql,返回结果(execute and return)
      其中,软、硬解析就发生在第三个过程里。
     ● Oracle利用内部的hash算法来取得该sql的hash值,然后在library cache里查找是否存在该hash值;
      ○ 假设存在,则将此sql与cache中的进行比较;
      ○ 假设“相同”,就将利用已有的解析树与执行计划,而省略了优化器的相关工作。这也就是软解析的过程。
     ● 诚然,如果上面的2个假设中任有一个不成立,那么优化器都将进行创建解析树、生成执行计划的动作。这个过程就叫硬解析。
     ● 创建解析树、生成执行计划对于sql的执行来说是开销昂贵的动作,所以,应当极力避免硬解析,尽量使用软解析。
     ● 这就是在很多项目中,倡导开发设计人员对功能相同的代码要努力保持代码的一致性,以及要在程序中多使用绑定变量的原因。
    ↩︎

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值