当前位置: 移动技术网 > IT编程>数据库>Oracle > Oracle中检查是否需要重构索引的sql

Oracle中检查是否需要重构索引的sql

2017年12月12日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:

select
height, /*height of the b-tree*/
blocks, /* blocks in the index segment */
name, /*index name */
lf_rows, /* number of leaf rows in the index */
lf_blks, /* number of leaf blocks in the index */
del_lf_rows, /* number of deleted leaf rows in the index */
rows_per_key /* average number of rows per distinct key */
blk_gets_per_access /* consistent mode block reads (gets) */
from index_stats
where name='index_name';

复制代码 代码如下:

analyze index index_name validate structure


height:
this column refers to the height of the b-tree index, and it's usually at the 1, 2, or 3 level.
if large inserts push the index height beyond a level of 4, it's time to rebuild, which flattens the b-tree.

del_lf_rows:
this is the number of leaf nodes deleted due to the deletion of rows.
oracle doesn't rebuild indexes automatically and, consequently, too many deleted leaf rows can lead to an unbalanced b-tree.

blk_gets_per_access:
you can look at the blk_gets_per_access column to see how much logical i/o it takes to retrieve data from the index. if this row shows a double-digit number, you should probably start rebuilding the index.

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网