前段时间维护数据需要将一张千万数量级表中cardno长度为9的数据cardtype更改为其他值,在cardtype和cardno上建有索引,
开始用 update card_table set cardtype='X' where cardtype='A' and length(cardno)=9 and rownum<100000
速度很快,过一段时间之后发现速度越来越慢;即使是查询
select count( cardno ) where cardtype='A' and length(cardno)=9 and rownum<100000 速度也很慢;
推测是由于做rangescan的时候 扫描太多不满足条件的数据,于是加上 index_desc的hint,果然查询快了很多
于是将更新修改为 update card_table set cardtype='X' where cardtype='A' and cardno like '1%' and length(cardno)=9 and rownum<100000
限定更新范围,果然速度有所提升。