1

I would like to know a couple of things regarding in operator in mysql.

  1. The number of values in the in operator, Is there a limit?
  2. Does it improve the performance if the values are sorted? Say employeeids. If the ids are given sorted in the criteria, Will it improve the performance?

1 Answers1

0
  1. Well, generally this number isn't directly limited, but you shouldn't exceed max_allowed_packet size with your query overall. SO basically there is a limit
  2. As far as I know, if you don't sort it yourself, mysql will do it for you.

But in case of a really large IN query consider replacing it with INNER JOIN with temporary table, containing all values. It will be faster.

Alexey
  • 2,388
  • 1
  • 16
  • 32