Please tell me from experience with using the “IN clause” in a MySQL query is considered to be too large of a list to push through to be considered good practice?
Example scenario is I have a string of user ID numbers that I will pull from a cache, it can range from anywhere from 1 number all the way up to being 5,000 numbers in this list and I will use a mysql query with this list like this example;
SELECT column FROM table
WHERE userid
IN ( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 )
Can you give me your thoughts on this issue please?
As long as your userid field is indexed, sounds like a good option.
Anyway, the real question here would be comparing the performance of IN against some other alternative. If that’s the only way to get your data, there’s not much you can do about it