MySQL:"IN"条目的入口是否有限制?条款? [英] MySQL: is there a limit to the entries of an "IN" clause?

查看:76
本文介绍了MySQL:"IN"条目的入口是否有限制?条款?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
"in子句"中的MySQL项目数

Possible Duplicate:
MySQL number of items within “in clause”
In mysql or postgres, is there a limit to the size of an IN (1,2,n) statement?

我动态建立一个"IN"列表,我想知道mysql中IN子句的大小是否有限制.

I build an "IN" list dynamically and I was wondering if there is a limit to the size of the IN clause in mysql.

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

我想象一个SQL语句的总长度是有限制的,但是我在手册中找不到它.

I imagine there is a limit to the total length of a SQL statement but I can't find it in the manual.

我确实知道一种替代方法是建立一个临时表并与之联接,尽管我不确定如果必须执行许多INSERT语句,性能折衷在哪里.当然,如果我可以用单个INSERT来填充临时表,那会很快,但是对于我而言,这是不可能的.

I do know that an alternative is to build a temp table and join with it, though I'm not sure where the performance tradeoff exists if I have to execute many INSERT statements. Of course if I could populate the temp table with a single INSERT that would be fast, but that's not possible in my case.

所以我的第一个问题是mysql的限制是多少,如果您能指出手册中的相关页面,我将不胜感激.

So my first question is what are the mysql limits and I'd appreciate if you can point me to relevant pages in the manual.

推荐答案

来自手册:

IN列表中的值数仅受

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

这篇关于MySQL:"IN"条目的入口是否有限制?条款?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆