当前位置: 代码迷 >> Oracle技术 >> not exists效率有关问题
  详细解决方案

not exists效率有关问题

热度:323   发布时间:2016-04-24 08:05:45.0
not exists效率问题
select l.aid  from location l  where not EXISTS (
     select r.boxaid  from resource r where  r.boxaid=l.aid
   )
其中表 location  的aid 与 表 resource 的boxaid 是对应关系
location  有500条数据左右   resource 有15万+的数据
这条语句执行一次需要40秒左右,有没有什么好的方法来实现同样的查询?
------解决思路----------------------
正常情况下,r.boxaid上有索引,且l.aid和r.boxaid的字段类型一致,即可
  相关解决方案