PostgreSQL - “IN"中的最大参数数条款? [英] PostgreSQL - max number of parameters in "IN" clause?

查看:26
本文介绍了PostgreSQL - “IN"中的最大参数数条款?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Postgres 中,您可以指定 IN 子句,如下所示:

In Postgres, you can specify an IN clause, like this:

SELECT * FROM user WHERE id IN (1000, 1001, 1002)

有谁知道你可以传入 IN 的最大参数数量是多少?

Does anyone know what's the maximum number of parameters you can pass into IN?

推荐答案

根据源码位于 这里,从第 850 行开始, PostgreSQL 没有明确限制参数的数量.

According to the source code located here, starting at line 850, PostgreSQL doesn't explicitly limit the number of arguments.

以下是第 870 行的代码注释:

The following is a code comment from line 870:

/*
 * We try to generate a ScalarArrayOpExpr from IN/NOT IN, but this is only
 * possible if the inputs are all scalars (no RowExprs) and there is a
 * suitable array type available.  If not, we fall back to a boolean
 * condition tree with multiple copies of the lefthand expression.
 * Also, any IN-list items that contain Vars are handled as separate
 * boolean conditions, because that gives the planner more scope for
 * optimization on such clauses.
 *
 * First step: transform all the inputs, and detect whether any are
 * RowExprs or contain Vars.
 */

这篇关于PostgreSQL - “IN"中的最大参数数条款?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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