Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit39baf9e

Browse files
committed
Draft
1 parentd898665 commit39baf9e

File tree

15 files changed

+807
-19
lines changed

15 files changed

+807
-19
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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>

‎src/backend/nodes/queryjumblefuncs.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,33 @@ JumbleQuery(Query *query)
140140
returnjstate;
141141
}
142142

143+
JumbleState*
144+
JumbleExpr(Expr*expr,uint64*exprId)
145+
{
146+
JumbleState*jstate=NULL;
147+
148+
Assert(exprId!=NULL);
149+
150+
jstate= (JumbleState*)palloc(sizeof(JumbleState));
151+
152+
/* Set up workspace for query jumbling */
153+
jstate->jumble= (unsignedchar*)palloc(JUMBLE_SIZE);
154+
jstate->jumble_len=0;
155+
jstate->clocations_buf_size=32;
156+
jstate->clocations= (LocationLen*)
157+
palloc(jstate->clocations_buf_size*sizeof(LocationLen));
158+
jstate->clocations_count=0;
159+
jstate->highest_extern_param_id=0;
160+
161+
/* Compute query ID */
162+
_jumbleNode(jstate, (Node*)expr);
163+
*exprId=DatumGetUInt64(hash_any_extended(jstate->jumble,
164+
jstate->jumble_len,
165+
0));
166+
167+
returnjstate;
168+
}
169+
143170
/*
144171
* Enables query identifier computation.
145172
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp