@@ -6314,6 +6314,63 @@ SELECT * FROM parent WHERE key = 2400;
63146314 </listitem>
63156315 </varlistentry>
63166316
6317+ <varlistentry id="guc-or-to-any-transform-limit" xreflabel="or_to_any_transform_limit">
6318+ <term><varname>or_to_any_transform_limit</varname> (<type>boolean</type>)
6319+ <indexterm>
6320+ <primary><varname>or_to_any_transform_limit</varname> configuration parameter</primary>
6321+ </indexterm>
6322+ </term>
6323+ <listitem>
6324+ <para>
6325+ Sets the minimum length of arguments in an <literal>OR</literal>
6326+ expression exceeding which planner will try to lookup and group
6327+ multiple similar <literal>OR</literal> expressions to
6328+ <literal>ANY</literal> (<xref linkend="functions-comparisons-any-some"/>)
6329+ expressions. The grouping technique of this transformation is based
6330+ on the equivalence of variable sides. One side of such an expression
6331+ must be a constant clause, and the other must contain a variable
6332+ clause. The default value is <literal>5</literal>. The value of
6333+ <literal>-1</literal> completely disables the transformation.
6334+ </para>
6335+ <para>
6336+ The advantage of this <literal>OR-to-ANY</literal> transformation is
6337+ faster query planning and execution. In certain cases, this
6338+ transformation also leads to more effective plans containing
6339+ a single index scan instead of multiple bitmap scans. However, it
6340+ may also cause a planning regression when distinct
6341+ <literal>OR</literal> arguments are better to match to distinct indexes.
6342+ This may happen when they have different matching partial indexes or
6343+ have different distributions of other columns used in the query.
6344+ Generally, more groupable <literal>OR</literal> arguments mean that
6345+ transformation will be more likely to win than to lose.
6346+ </para>
6347+ <para>
6348+ For example, this query has its set of five <literal>OR</literal>
6349+ expressions transformed to <literal>ANY</literal> with the default
6350+ value of <varname>or_to_any_transform_limit</varname>. But not with
6351+ the increased value.
6352+ <programlisting>
6353+ # EXPLAIN SELECT * FROM tbl WHERE key = 1 OR key = 2 OR key = 3 OR key = 4 OR key = 5;
6354+ QUERY PLAN
6355+ -----------------------------------------------------
6356+ Seq Scan on tbl (cost=0.00..51.44 rows=64 width=4)
6357+ Filter: (key = ANY ('{1,2,3,4,5}'::integer[]))
6358+ (2 rows)
6359+
6360+ # SET or_to_any_transform_limit = 6;
6361+ SET
6362+
6363+ # EXPLAIN SELECT * FROM tbl WHERE key = 1 OR key = 2 OR key = 3 OR key = 4 OR key = 5;
6364+ QUERY PLAN
6365+ ---------------------------------------------------------------------------
6366+ Seq Scan on tbl (cost=0.00..67.38 rows=63 width=4)
6367+ Filter: ((key = 1) OR (key = 2) OR (key = 3) OR (key = 4) OR (key = 5))
6368+ (2 rows)
6369+ </programlisting>
6370+ </para>
6371+ </listitem>
6372+ </varlistentry>
6373+
63176374 <varlistentry id="guc-plan-cache-mode" xreflabel="plan_cache_mode">
63186375 <term><varname>plan_cache_mode</varname> (<type>enum</type>)
63196376 <indexterm>
0 commit comments