MySQL IN condition limit

南楼画角 提交于 2019-12-17 10:31:25

问题


Hey, I have to use IN condition in my MySQL statement with a large set of ids.

Example

SELECT * FROM users WHERE id IN (1,2,3,4...100000)

Is there a limit if items the IN statement can have?


回答1:


No there isn't, check the manual about the IN function:

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




回答2:


As far as I know in mysql, there is no limit for items in the IN statement.

In oracle altough, there is a limit of 1000 items in the IN statement.

But more the items in IN, your query performance will slow down unless that column is indexed.




回答3:


1073741824 This is the limit given in Mysql docs



来源:https://stackoverflow.com/questions/4275640/mysql-in-condition-limit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!