I'm thinking about using https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_field, but it doesn't say anything about any limits in terms of how many values it can support.
Does anyone have any insight into this? Thanks!
I'm thinking about using https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_field, but it doesn't say anything about any limits in terms of how many values it can support.
Does anyone have any insight into this? Thanks!
I'm not aware that there's any limit on the number of arguments to the FIELD() function per the grammar. I assume it's limited by the max length of an SQL query.
The limit on the length of any SQL query is determined by max_allowed_packet
in bytes. The default for this variable in MySQL 5.7 is 4MB. It can be increased up to 1GB. https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_allowed_packet
I agree with @Uueerdo — If you're generating a list of expressions longer than 4MB, you should really question if your approach to your task is the best way of solving it.
I'd guess that the FIELD() function will compare the arguments in a linear fashion, because the implementation probably never guessed that anyone would feed it very long lists. So searching through tens of thousands of arguments for every row will probably be a bad performance bottleneck.