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 <lepihov@gmail.com>
Discussion: https://postgr.es/m/3ac7c436-81e1-4191-9caf-b0dd70b51511%40gmail.com
Reviewed-by: Pavel Borisov <pashkin.elfe@gmail.com>
Reviewed-by: Andrei Lepikhov <lepihov@gmail.com>
Reviewed-by: Alena Rybakina <a.rybakina@postgrespro.ru>
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(-)