in 和 or 的效率问题

select * from table where col in (2,3,4,5,6)

select * from table where col=2 or col=3 or col=4 or col=5 or col=6 

当col有索引的时候,in和or都会走索引,效率差不多

当col没索引的时候,in 的效率比or高,in是log  or 是n

posted @ 2018-10-19 16:11  为爱奋斗不息  阅读(2810)  评论(0编辑  收藏  举报