MYSQL OR vs IN performance

后端 未结 14 1010
一向
一向 2020-11-22 04:12

I am wondering if there is any difference in regards to performance between the following

SELECT ... FROM ... WHERE someFIELD IN(1,2,3,4)

SELECT ... FROM ..         


        
14条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 04:50

    From what I understand about the way that the compiler optimizes these types of queries, using the IN clause is more efficient than multiple OR clauses. If you have values where the BETWEEN clause can be used, that is more efficient still.

提交回复
热议问题