简体   繁体   English

MySQL IN 条件限制

[英]MySQL IN condition limit

Hey, I have to use IN condition in my MySQL statement with a large set of ids.嘿,我必须在具有大量 ID 的 MySQL 语句中使用 IN 条件。

Example例子

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

Is there a limit if items the IN statement can have? IN语句可以包含的项目是否有限制?

No there isn't, check the manual about the IN function :不,没有,请查看有关 IN 功能手册

The number of values in the IN list is only limited by the max_allowed_packet value. IN列表中值的数量仅受max_allowed_pa​​cket值的限制。

As far as I know in mysql, there is no limit for items in the IN statement.据我所知,在 mysql 中, IN语句中的项目没有限制。

In oracle altough, there is a limit of 1000 items in the IN statement.在 oracle 中, IN语句中有 1000 项的限制。

But more the items in IN , your query performance will slow down unless that column is indexed.但是IN的项目越多,除非该列被索引,否则您的查询性能会变慢。

在此处输入图片说明

1073741824 This is the limit given in Mysql docs 1073741824 这是 Mysql 文档中给出的限制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM