How many values in an “in” clause is too many in a SQL query?

前端 未结 4 1354
挽巷
挽巷 2021-02-12 19:14

I have a SQL query that uses the values of an array in its WHERE clause:

 $ids = array 
         ( 
           [0] => 1 
           [1] => 2 
           [2         


        
4条回答
  •  梦如初夏
    2021-02-12 19:52

    The more data you select, the longer this takes, but your primary concern should not be the number of ids you SELECT. Instead, you should ensure that your id has an INDEX on it or that it is the PRIMARY KEY. This will make lookups fast no matter how many ids you're grabbing.

提交回复
热议问题