首先说一点,这个问题和redolog无关,redolog是oralce运行机制的一部分,必须使用,最多是测试环境归档日志没开。
表插入大批量数据再删除后,查询速度慢的问题,关键是使用delete语句删除记录后,表占用的空间没有释放,在oracle中的说法就是HWM保持不变,因此查询的时候即使只有几条记录,如果全表扫描的话仍会花费大量的时间,如果是临时表需要定期清理数据,使用truncate table更合适一些。
oracle官方对truncate操作的说明:
Use the TRUNCATE TABLE statement to remove all rows from a table. By default, Oracle Database also performs the following tasks:
Deallocates all space used by the removed rows except that specified
by the MINEXTENTS storage parameter
Sets the NEXT storage parameter to the size of the last extent removed
from the segment by the truncation process
生产环境如果无法使用truncate,可以使用下面的方法降低HWM
方法一:
alter table table_name move
完成后需要重新创建索引
方法二:
alter table table_name enable row movement;
alter table table_name shrink space;