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的字段类型一致,即可