日期:2014-05-16  浏览次数:21102 次

Oracle数据库sql查询缓慢问题
select count(*) as RowCount from table1 where 
Status is null and exists(select reference from table2 where actionUser = 'xxx' and flow = 'yyy' and table2.reference = table1.reference)
or  Status = 'st'
我在Oracle数据库中执行这句语句查询的时候,非常缓慢,通常要等待40秒左右才会给出查询结果
但是如果去掉 or Status = 'st' 就非常快,1秒都不到
求高手大大们帮下忙,看看什么原因导致查询缓慢。
------解决方案--------------------
Status 字段上是不是没有索引,你查一下执行计划,看是走索引还是全表扫描
------解决方案--------------------
那你应该是Status 没建索引吧,is null 是走全表扫描的,
如果建了索引很是很慢 or 换成union all试试?