oracle analyze原理,Oracle analyze 介绍

使用 Analyze 命令可以收集统计信息,例如:

收集或者删除索引或者分区表索引,表或者分区表,索引组织表。

校验索引或者分区索引,表或者分区表,索引组织表,聚族表,引用对象(object reference) 的结构。

确定表或者聚族表的行迁移以及行链接。

1. analyze table

oracle 数据库收集以下表内容的统计信息,前面标上*号的通常是准确统计的,表的统计信息包括主要索引的状态信息都将会写到数据字典 view 中,例如 user_tables, all_tables, dba_tables

行数(num_rows)

* 高水位下的数据块的数量(blocks)

* 未分配的数据块(empty_blocks)

每个块的平均可用空间(avg_space)

行链接行的数量(chain_count)

行平均长度(avg_row_len)

使用 analyze table 有以下限制

不能使用 analyze 收集数据字典表的统计信息

不能使用 analyze 收集外部表的统计信息,只能用 dbms_stats 包

不能使用 analyze 收集临时表(temporary table)的默认统计信息

不能计算或是估算以下列类型的统计信息,引用类型(ref column types),数组(varrays),嵌套表(nested tables), Lob,long 以及对象类型

2. analyze index

oracle 数据库通常收集以下索引的统计信息,前面标上*号的通常是准确统计的,这些信息将会保存在数据字典 view 中, 如 user_indexes, all_indexes, dba_indexes

* 索引从 root 数据块 到叶子数据块的深度(blevel)

叶子数据块的数量(leaf_blocks)

索引不同值得数量(distinct_keys)

每个索引值的平均叶子数据块的数据(avg_leaf_blocks_per_key)

每个索引值得平均数据块的数据(avg_data_blocks_per_key)

聚合因子(clustering_factor)

analyze 索引的限制:

不能使用 analyze 计算或者估算被标示为 in_process 或者 failed 的索引

3. analyze cluster

当使用 analyze 收集聚族表的统计信息时,oracle 会自动收集聚族所有的表和索引。

4. list chained rows

list chained rows 可以用来分析表或者是聚族表上是否有行迁移和行链接。

使用 list chained rows 分析前需要先创建表 chained_rows,可以调用 utlchain.sql。

5. 详细语法语句如下

analyze table table_name compute/estimate/delete statistics [patition()/subpartition()]

analyze index index_name compute/estimate/delete statistics [patition()/subpartition()]

analyze cluster cluster_name compute/estimate/delete statistics [patition()/subpartition()]

-- 删除 orders 表和索引统计信息

analyze table orders delete statistics;

-- 校验 index 的结构

anlayze index inv_order_ix validate structure;

-- 校验表 orders 以及 orders 上的索引

analyze table orders validate structure cascade;

-- 分析 orders 表上是否有行迁移/行链接

analyze table orders list chained rows into chained_rows;

6. 统计信息的生成有两种方式

(1). 完全计算,这种方式需要全表扫描,因此需要花费较长的时间

analyze table table_name compute statistics

(2). 估算, 这种方式通过动态采集抽样部分数据进行估算,因此花费的时间较少

analyze table table_name estimate statistics sample 30 percent

7. analyze 与 dbms_stats 包的区别

analyze 与 dbms_stats 包都可以用来收集表,列,索引的统计信息,oracle 一般建议使用 dbms_stats 包来收集统计信息

(1) analyze 不能收集系统统计信息和内部对象的统计信息

(2) analyze 不能准确的收集分区表的统计信息,而 dbms_stats 包却可以

(3) analyze 不能并行收集统计,而 dbms_stats 包却可以

(4) analyze 可以收集行迁移和行链接的数量以及校验表,索引,而 dbms_stats 包却不可以

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值