Don't zero tuple_fraction when planning UNIONs with ORDER BYs
authorDavid Rowley <drowley@postgresql.org>
Tue, 2 Apr 2024 22:40:33 +0000 (11:40 +1300)
committerDavid Rowley <drowley@postgresql.org>
Tue, 2 Apr 2024 22:40:33 +0000 (11:40 +1300)
commit3b1a7eb28930e9835cda5e42256b7ccc2d044d41
treee4944e73b9b5018b48c74f0db69d864026dffc4a
parent06c418e163e913966e17cb2d3fb1c5f8a8d58308
Don't zero tuple_fraction when planning UNIONs with ORDER BYs

Since 66c0185a3, the planner is able to use Merge Append -> Unique to
implement UNION queries and each subquery is prompted to produce Paths
correctly sorted by the UNION's targetlist.

Here we remove some now redundant code which was zeroing the
tuple_fraction at the parent level.  This will allow the planner to
consider cheap startup paths when planning the UNION's subqueries.

EXCEPT and INTERSECT set operations still have the tuple_fraction zeroed
in generate_nonunion_paths().  These operations currently always read
all of their subqueries' tuples.

Reported-by: Tom Lane
Discussion: https://postgr.es/m/3703023.1711654574@sss.pgh.pa.us
src/backend/optimizer/plan/planner.c