【信息统计】dbms_stat 的文档

简介:

General
Note: The drawback to collecting REDUNDANT column stats is that they have to be loaded into the dictionary cache, and they have to be considered when the query is optimised. This waste shared pool space and CPU.

On the other hand, if the statistics add value about the data - which does mean EVEN on unindexed columns - queries can run faster.

Most systems should have only a few column histograms in place, but there is no obvious requirement that they should only be on indexed columns.
Source {ORACLE_HOME}/rdbms/admin/dbmsstat.sql
First Available 8.1.5
Character Sets For DBMS_STATS to run properly may require the US numeric separators. If problems exist try the following:

alter session set NLS_NUMERIC_CHARACTERS='.,';

Constants Constant Data Type Usage
AUTO_CASCADE BOOLEAN Whether to collect statistics for indexes or not
AUTO_DEGREE NUMBER Select the degree of parallelism
AUTO_INVALIDATE BOOLEAN Decide when to invalidate dependent cursors
AUTO_SAMPLE_SIZE NUMBER Indicate that auto-sample size algorithms should be used
DEFAULT_DEGREE NUMBER Used to determine the system default degree of parallelism
 

Default Constants Constant Data Type Value
DEFAULT_CASCADE BOOLEAN NULL
DEFAULT_DEGREE_VALUE NUMBER 32766
DEFAULT_ESTIMATE_PERCENT NUMBER 101
DEFAULT_METHOD_OPT VARCHAR2(1) 'Z'
DEFAULT_NO_INVALIDATE BOOLEAN NULL
DEFAULT_GRANULARITY VARCHAR2(1) 'Z'
DEFAULT_PUBLISH BOOLEAN TRUE
DEFAULT_INCREMENTAL BOOLEAN FALSE
DEFAULT_STALE_PERCENT NUMBER 10
DEFAULT_AUTOSTATS_TARGET VARCHAR2(1) 'Z'
 

Method_opt Constants Accepts:

* FOR ALL [INDEXED | HIDDEN] COLUMNS [size_clause]
* FOR COLUMNS [size clause] column|attribute [size_clause] [,column|attribute [size_clause]...]

size_clause is defined as size_clause := SIZE {integer | REPEAT | AUTO | SKEWONLY}

- integer : Number of histogram buckets: Range [1,254].
- REPEAT : Collects histograms only on columns that already have
histograms.
- AUTO : Determines the columns to collect histograms based on
data distribution and the workload of the columns.
- SKEWONLY : Determines the columns 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_PARAM Procedure.
Degree Constants Degree of parallelism. The default for degree is NULL. The default value can be changed using the SET_PARAM 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 either 1 (serial execution) or DEFAULT_DEGREE (the system default value based on number of CPUs and initialization parameters) according to size of the object.

Granularity Constants Granularity of statistics to collect (only pertinent if the table is partitioned).
Constant Description
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
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
 

Data Types TYPE numarray IS VARRAY(256) OF NUMBER;
TYPE datearray IS VARRAY(256) OF DATE;
TYPE chararray IS VARRAY(256) OF VARCHAR2(4000);
TYPE rawarray IS VARRAY(256) OF RAW(2000);
TYPE fltarray IS VARRAY(256) OF BINARY_FLOAT;
TYPE dblarray IS VARRAY(256) OF BINARY_DOUBLE;

TYPE StatRec IS RECORD (
epc    NUMBER,
minval RAW(2000),
maxval RAW(2000),
bkvals NUMARRAY,
novals NUMARRAY,
chvals CHARARRAY,
eavs   NUMBER);

Types for listing stale tables include:
TYPE ObjectElem IS RECORD (
ownname     VARCHAR2(30), -- owner
objtype     VARCHAR2(6),   -- 'TABLE' or 'INDEX'
objname     VARCHAR2(30), -- table/index
partname    VARCHAR2(30), -- partition
subpartname VARCHAR2(30), -- subpartition
confidence NUMBER);       -- not used

TYPE ObjectTab IS TABLE OF ObjectElem;
/

Dependencies SELECT name
FROM dba_dependencies
WHERE referenced_name = 'DBMS_STATS'
UNION
SELECT referenced_name
FROM dba_dependencies
WHERE name = 'DBMS_STATS';

Exceptions Error Code Reason
20000 Table already exists or insufficient privileges (or) Insufficient privileges
(or) Index does not exist or insufficient privileges (or) Object does not exist or insufficient privileges
20001 Tablespace does not exist (or) Bad input value (or) Invalid or inconsistent values in the user statistics table
20002 Bad user statistics table; may need to be upgraded
20003 Unable to set system statistics (or) Unable to gather system statistics
20004 Parameter does not exist (or) Error in the INTERVAL mode: system parameter job_queue_processes must be >0
20005 Object statistics are locked
20006 Unable to restore statistics, statistics history not available
 

Granularity Parameters Parameter Description
ALL Gathers all (subpartition, partition, and global) stats.
AUTO Determines the granularity based on the partitioning type, and collects the global, partition level and subpartition level statistics if the subpartitioning method is LIST, and the global and partition level only otherwise. 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.
 

Options Parameters Parameter Description
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 determined by looking at the *_tab_modifications views
LIST EMPTY Returns a list of objects which currently have no statistics
 

pname Parameter for GET and SET PARAM Parameter Description
CASCADE The default value for CASCADE set by SET_PARAM is not used by export/import procedures.It is used only by gather procedures
DEGREE Degree of parallelism
ESTIMATE_PERCENT 
METHOD_OPT 'FOR COLUMNS REPEAT'
'FOR ALL COLUMNS SIZE REPEAT'
'FOR ALL COLUMNS SIZE 1'
NO_VALIDATE 
 

pname Parameter for GET_SYSTEM_STATS Parameter Description
CPUSPEED Average number of CPU cycles for each second, in millions, captured for the workload (statistics collected using 'INTERVAL' or 'START' and 'STOP' options)
SPUSPEEDNW Average number of CPU cycles for each second, in millions, captured for the noworkload (statistics collected using 'NOWORKLOAD' option
IOSEEKTIM Seek time + latency time + operating system overhead time, in milliseconds
IOTFRSPEED I/O transfer speed in bytes for each millisecond
MAXTHR Maximum I/O system throughput, in bytes/second
MBRC Average multiblock read count for sequential read, in blocks
MREADTIM Average time to read an mbrc block at once (sequential read), in milliseconds
SLAVETHR Average slave I/O throughput, in bytes/second
SREADTIM Average time to read single block (random read), in milliseconds
 
System Privileges For some of the DBMS_STATS procedures one or more of the following may be required:

ANALYZE ANY DICTIONARY
ANALYZE ANY
Enable automatic statistics collection exec dbms_scheduler.enable('GATHER_STATS_JOB');
Disable automatic statistics collection exec dbms_scheduler.disalbe('GATHER_STATS_JOB'); 

相关文章
|
JavaScript 数据安全/隐私保护
使用vue+vant制作的一个个人信息展示页面
使用vue+vant制作的一个个人信息展示页面
1376 0
|
6月前
|
Java Go 数据安全/隐私保护
企业级即时通讯源码_WebSocket聊天室源码_Java/Go/Flutter多版本
本文深度解析企业级IM源码,涵盖Java/Go双后端微服务架构、WebSocket实时聊天室、Flutter跨端客户端及E2EE加密等核心实践,兼顾高并发、私有化部署与系统集成,助力企业构建安全、可控、可扩展的通信中台。
|
人工智能 运维 监控
【2025云栖大会】AI 搜索引擎如何驱动亿级物流:货拉拉 x 阿里云 Elasticsearch
2025云栖大会 AI搜索与向量化模型专场上,拉拉 Elasticsearch技术负责人——陈敏华先生分享了 Elasticsearch 在全球化高并发业务场景下的深度实践,以及在迁移至阿里云 Elasticsearch Serverless 后的显著收益。货拉拉的案例为业界提供了可复制、可落地的技术范本。
951 4
|
6月前
|
人工智能 安全 语音技术
别再让 AI 只会聊天了!Hermes Agent 自带 47 个实用工具,一键解锁智能体真正实力
Hermes Agent 内置 47 个实用工具,覆盖网络搜索、终端执行、浏览器自动化、AI 绘图等 8 大类别,可一键启用工具集。本文带你全面掌握智能体工具使用,释放 AI 全能力。
963 0
|
10月前
|
API 开发工具 git
Dify部署与API调用教程
本文档详解Dify本地部署全流程:先安装Docker与Git;再克隆GitHub源码、复制配置;最后访问localhost/apps完成初始化,集成CanopyWave插件并配置专属API密钥,即可调用全部AI模型。(239字)
4185 0
|
11月前
|
机器学习/深度学习 JSON 算法
大模型对齐实战:从原理到代码,透彻理解PPO微调全流程
* **PPO是什么**:一种稳定、高效的强化学习算法,通过“近端”优化和“优势”估计,在追求高奖励的同时,用KL散度约束策略不偏离太远。 * **PPO微调做什么**:利用奖励模型(代表人类偏好)作为引导,优化语言模型的生成策略,使其输出更对齐人类价值观。 * **四大核心**:**Actor**(被优化者)、**Critic**(价值评估者)、**Reward Model**(评分官)、**Reference Model**(守门员/底线)四者协同工作。 * **核心价值**:解决了SFT难以处理的复杂、动态、多目标权衡的对齐问题,是打造如ChatGPT般“好用”模型的关键
|
机器学习/深度学习 自然语言处理 监控
淘宝API揭秘:如何让你的店铺在海量商品中脱颖而出?
在淘宝海量商品中突围,需借助API实现精细化运营。本文详解商品管理、搜索优化、数据智能与营销互动四大类API应用,助力商家提升效率、精准引流、科学决策,实现智能化升级。(238字)
|
消息中间件 存储 缓存
批量获取淘宝商品评论:API 分页策略、并发控制与频率优化
批量获取淘宝商品评论:API 分页策略、并发控制与频率优化
|
人工智能 自然语言处理 安全
AI人格的创世蓝图:深度解构《自衍体》的意识架构设计
本文深度解析前沿开源项目《自衍体》(Zyantine),探讨其如何通过“核心本能、欲望引擎、辩证成长、认知表达”四大支柱,构建具备稳定人格的AI Agent。项目以“内在世界”为核心,提出认知流与事实锚定协议,为下一代“有格”AI奠定理论与工程基础,标志着AI从行为模拟走向人格建构的新纪元。
|
Linux Shell 开发工具
Linux文件内容查看和编辑指南:cat、less、grep等常用命令详解(一)
Linux文件内容查看和编辑指南:cat、less、grep等常用命令详解(一)
3705 0