语句1:
select a from abc where h = 1 and k = 2 and a not in (select c from bns where s =1)
语句2:
select a from abc where h = 1 and k = 2 and not (a in (select c from bns where s =1))
这2个语句之间效率上哪一个更好?还有那些方式比not in效率高一些的?
讨论帖子,欢迎大家来讨论一下。能从执行过程,执行原理上讨论就更好了。欢迎底层的一些解释。
select a from abc where h = 1 and k = 2 and a not in (select c from bns where s =1)
语句2:
select a from abc where h = 1 and k = 2 and not (a in (select c from bns where s =1))
这2个语句之间效率上哪一个更好?还有那些方式比not in效率高一些的?
讨论帖子,欢迎大家来讨论一下。能从执行过程,执行原理上讨论就更好了。欢迎底层的一些解释。
not in 他必须扫描全表才可以确定查找的内容是否存在,
如果是in的话..找到了之后你就停止了本次扫描..继续下次的搜索..
如果a字段上建立的索引,情况也一样,因为索引只可以加快搜索存在的值,
而不可以提高没有值的搜索.