On 24.02.2024 14:28, jian he wrote:
Hi.
I wrote the first draft patch of the documentation.
it's under the section: Planner Method Configuration (runtime-config-query.html)
but this feature's main meat is in src/backend/parser/parse_expr.c
so it may be slightly inconsistent, as mentioned by others.

You can further furnish it.

Thank you for your work. I found a few spelling mistakes - I fixed this and added some information about generating a partial index plan. I attached it.

--
Regards,
Alena Rybakina
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
From e3a0e01c43a70099f6870a468d0cc3a8bdcb2775 Mon Sep 17 00:00:00 2001
From: Alena Rybakina <a.rybak...@postgrespro.ru>
Date: Mon, 26 Feb 2024 06:37:36 +0300
Subject: [PATCH] doc1

---
 doc/src/sgml/config.sgml | 74 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 36a2a5ce431..47f82ca2dc9 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -5294,6 +5294,80 @@ ANY <replaceable 
class="parameter">num_sync</replaceable> ( <replaceable class="
       </listitem>
      </varlistentry>
 
+     <varlistentry id="guc-enable-or-transformation" 
xreflabel="enable_or_transformation">
+      <term><varname>enable_or_transformation</varname> (<type>boolean</type>)
+       <indexterm>
+        <primary><varname>enable_or_transformation</varname> configuration 
parameter</primary>
+       </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Enables or disables in query planner's ability to transform multiple 
expressions in (<xref linkend="sql-expressions"/>)
+        <xref linkend="sql-where"/> to a ANY expression (<xref 
linkend="functions-comparisons-any-some"/>).
+        This transformations only apply under the following condition:
+        <itemizedlist>
+          <listitem>
+          <para>
+            Each expression should be formed as: 
<replaceable>expression</replaceable> <replaceable>operator</replaceable>  
(<replaceable>expression</replaceable>).
+            The right-hand side of the operator should be just a plain 
constant.
+            The left-hand side of these expressions should remain unchanged.
+          </para>
+          </listitem>
+        </itemizedlist>
+        <itemizedlist>
+          <listitem>
+          <para>
+            At the stage of index formation, a check is made on the 
restructuring of the plan using partial indexes or the formation of expressions 
combined by the "OR" <replaceable>operator</replaceable>.
+          </para>
+          </listitem>
+        </itemizedlist>
+            <itemizedlist>
+              <listitem>
+                <para>
+                  Each expression form should return Boolean (true/false) 
result.
+                </para>
+              </listitem>
+            </itemizedlist>
+            <itemizedlist>
+              <listitem>
+                <para>
+                These expressions are logically linked in a OR condition.
+                </para>
+              </listitem>
+            </itemizedlist>
+          The default is <literal>on</literal>.
+          </para>
+        <para>
+          For example, the following query without setting 
<varname>enable_or_transformation</varname> is usually applied to the three 
filtering conditions separately,
+          but if we set <varname>enable_or_transformation</varname>, we 
combine the three expressions into only one expression: <literal>unique1 = ANY 
('{1,2,3}'::integer[]) </literal>.
+          <programlisting>
+          EXPLAIN SELECT * FROM tenk1 WHERE unique1 = 1 or unique1 = 2 or 
unique1 = 3;
+
+                                  QUERY PLAN
+          -------------------------------------------------------------
+          Seq Scan on tenk1  (cost=0.00..482.50 rows=3 width=244)
+            Filter: (unique1 = ANY ('{1,2,3}'::integer[]))
+          </programlisting>
+        </para>
+        <para>
+          Another example is the following query with a given 
<varname>enable_or_transformation</varname> value, but we have generated a plan 
with partial indexes.
+          <programlisting>
+          EXPLAIN SELECT unique2, stringu1 FROM onek2 WHERE unique1 = 1 OR 
unique1 = PI()::integer;
+                              QUERY PLAN                    
+          --------------------------------------------------
+          Bitmap Heap Scan on onek2
+            Recheck Cond: ((unique1 = 3) OR (unique1 = 1))
+            ->  BitmapOr
+                  ->  Bitmap Index Scan on onek2_u1_prtl
+                        Index Cond: (unique1 = 3)
+                  ->  Bitmap Index Scan on onek2_u1_prtl
+                        Index Cond: (unique1 = 1)
+          (7 rows)
+          </programlisting>
+        </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-enable-parallel-append" 
xreflabel="enable_parallel_append">
       <term><varname>enable_parallel_append</varname> (<type>boolean</type>)
       <indexterm>
-- 
2.34.1

Reply via email to