MYSQL OR vs IN performance

后端 未结 14 1113
一向
一向 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 05:01

    As explained by others, IN is better chosen than OR with respect to query performance.

    Queries with OR condition might take more longer execution time in the below cases.

    1. to execute if MySQL optimizer choses any other index to be efficient(during false positive cases).
    2. If the number of records is more ( As clearly stated by Jacob )

提交回复
热议问题