pgsql: Fix tuple_fraction calculation in generate_orderedappend_paths()

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix tuple_fraction calculation in generate_orderedappend_paths()
Date: 2025-05-18 20:51:10
Message-ID: E1uGkyT-002I7v-2b@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix tuple_fraction calculation in generate_orderedappend_paths()

6b94e7a6da adjusted generate_orderedappend_paths() to consider fractional
paths. However, it didn't manage to interpret the tuple_fraction value
correctly. According to the header comment of grouping_planner(), the
tuple_fraction >= 1 specifies the absolute number of expected tuples. That
number must be divided by the expected total number of tuples to get the
actual fraction.

Even though this is a bug fix, we don't backpatch it. The risks of the side
effects of plan changes on stable branches are too high.

Reported-by: Andrei Lepikhov <lepihov(at)gmail(dot)com>
Discussion: https://postgr.es/m/3ca271fa-ca5c-458c-8934-eb148622b270%40gmail.com
Author: Andrei Lepikhov <lepihov(at)gmail(dot)com>
Reviewed-by: Junwang Zhao <zhjwpku(at)gmail(dot)com>
Reviewed-by: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3d3a81fc24b07f04df81d898f6b4e85c553ef604

Modified Files
--------------
src/backend/optimizer/path/allpaths.c | 12 +++++++++++-
src/test/regress/expected/partition_join.out | 18 ++++++++++++++++++
src/test/regress/sql/partition_join.sql | 3 +++
3 files changed, 32 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-05-19 00:45:14 pgsql: ecpg: Add missing newline in meson.build
Previous Message Tom Lane 2025-05-18 16:46:18 pgsql: Make our usage of memset_s() conform strictly to the C11 standar