MYSQL OR vs IN performance

后端 未结 14 1005
一向
一向 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:42

    OR will be slowest. Whether IN or BETWEEN is faster will depend on your data, but I'd expect BETWEEN to be faster normally as it can simple take a range from an index (assuming someField is indexed).

提交回复
热议问题