Oracle-降低表的高水位线

Oracle-降低表的高水位线

在应用中存在一系列的表,对表的操作是批量插入又批量删除,最终导致表的水位线很高。高水位线影响全索引扫描的SQL。即影响系统的性能。

现有方法降低表的水位线:

1、降低表的高水位线
select 'alter table '||TABLE_NAME||' move tablespace '||TABLESPACE_NAME||';' from user_tables where table_name='&TABLE_NAME';
2、重建表上的索引
select 'alter index '||index_name||' rebuild online;' from user_indexes where table_name='&TABLE_NAME';
3、收集表上的统计信息
select 'analyze table '||TABLE_NAME||' compute statistics;' from user_tables where table_name='&TABLE_NAME';
4、收集索引上的统计信息
select 'analyze index '||index_name||' compute statistics;' from user_indexes where table_name='&TABLE_NAME';

注意:

1、需将对应的表名替换'&TABLE_NAME',表名要大写,依次执行上述步骤的“查询结果”;

2、需停服务执行,否则脚本报错;