MYSQL OR vs IN performance

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

    It depends on what you are doing; how wide is the range, what is the data type (I know your example uses a numeric data type but your question can also apply to a lot of different data types).

    This is an instance where you want to write the query both ways; get it working and then use EXPLAIN to figure out the execution differences.

    I'm sure there is a concrete answer to this but this is how I would, practically speaking, figure out the answer for my given question.

    This might be of some help: http://forge.mysql.com/wiki/Top10SQLPerformanceTips

    Regards,
    Frank

提交回复
热议问题