MySQL: is there a restriction on records in the "IN" section?

Possible duplicate:
MySQL the number of elements in the section in the section
In mysql or postgres, is there a limit on the size of the IN (1,2, n) statement?

I am building the "IN" list dynamically, and I was wondering if there is a size limit on the IN clause in mysql.

SELECT foo FROM bar WHERE bar_key IN ('prod1', 'prod2', 'prod50', ...'last prod') 

I assume that there is a limit on the total length of the SQL statement, but I cannot find it in the manual.

I know that an alternative is to create a temporary table and join with it, although I'm not sure where a performance trade-off exists if I need to execute many INSERT statements. Of course, if I could fill the temp table with one INSERT, which would be fast, but that is not possible in my case.

So, my first question is what are the mysql limits, and I would appreciate it if you could give me the relevant pages in the manual.

+4
source share
1 answer

From the manual:

The number of values ​​in the IN list is limited only by the value max_allowed_packet .

+9
source

Source: https://habr.com/ru/post/1390296/


All Articles