select * from a
where col1 > 'T040'
这样速度很快
select * from a
where col1 between 'T040' and 'T090'
这样速度慢到死掉进程
请问为什么?
select * from a
where col1 > 'T040'
这样速度很快
select * from a
where col1 between 'T040' and 'T090'
这样速度慢到死掉进程
请问为什么?
首先,你对字符串用 大于、小于比较本身就比较慢。
然后 where col1 > 'T040' 这一句按说会全表扫描。
对字符串用大于 小于 是不会走索引的
所以 between 'T040' and 'T090'
或者 where col1 > 'T040' and col1 <'T090'
都会进行两次全表扫描。
还有原因 between 其实 >= and <= 有可能你'T040' 和'T090'
的数据特别多。返回时在排列行又有额外的消耗。
具体,你在plsql上按下f5 看看执行计划 发过来再讨论。