delete from userinfo where id in (1,2,3,4,5,6)
delete from userinfo where id=1 or id=2 or id=3 or id=4 or id=5 or id=6
这两条sql语句那种效率会好一点,有什么区别?
数据量大的话下面的效率能好点,在sql语句中尽量不要使用in not in like 等词,很影响执行效率
看一下本机的执行计划。
效率是一样的。
引用 http://stackoverflow.com/a/2110741 :
Due to Sql Server's optimization of queries these will run at the same speed since they are logically equivalent.
一模一样。