public inbox for [email protected]  
help / color / mirror / Atom feed
From: Alexander Korotkov <[email protected]>
To: [email protected]
Subject: pgsql: Make group_similar_or_args() reorder clause list as little as po
Date: Fri, 28 Mar 2025 21:37:55 +0000
Message-ID: <[email protected]> (raw)

Make group_similar_or_args() reorder clause list as little as possible

Currently, group_similar_or_args() permutes original positions of clauses
independently on whether it manages to find any groups of similar clauses.
While we are not providing any strict warranties on saving the original order
of OR-clauses, it is preferred that the original order be modified as little
as possible.

This commit changes the reordering algorithm of group_similar_or_args() in
the following way.  We reorder each group of similar clauses so that the
first item of the group stays in place, but all the other items are moved
after it.  So, if there are no similar clauses, the order of clauses stays
the same.  When there are some groups, only required reordering happens while
the rest of the clauses remain in their places.

Reported-by: Andrei Lepikhov <[email protected]>
Discussion: https://postgr.es/m/3ac7c436-81e1-4191-9caf-b0dd70b51511%40gmail.com
Reviewed-by: Pavel Borisov <[email protected]>
Reviewed-by: Andrei Lepikhov <[email protected]>
Reviewed-by: Alena Rybakina <[email protected]>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/775a06d44c04e323158826ec256386e7211e154d

Modified Files
--------------
src/backend/optimizer/path/indxpath.c        | 59 +++++++++++++++++++++++++++-
src/test/regress/expected/create_index.out   | 49 ++++++++++++++++++-----
src/test/regress/expected/join.out           | 52 ++++++++++++------------
src/test/regress/expected/partition_join.out | 12 +++---
src/test/regress/sql/create_index.sql        | 11 ++++++
5 files changed, 141 insertions(+), 42 deletions(-)



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: Make group_similar_or_args() reorder clause list as little as po
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox