On Mon, Nov 3, 2025 at 7:09 PM Richard Guo <guofenglinux@gmail.com> wrote:
> Thanks for the report -- that's a good catch.  However, I don't think
> we should use childrel->rows to calculate the fraction in the first
> place.  It would be better to use cheapest_total->rows instead.
Reading generate_orderedappend_paths(), I noticed a couple of other
issues:
1. This function considers the cheapest-fractional case in addition to
the cheapest-startup and cheapest-total cases, but the function's
comment does not mention this.
 * We consider both cheapest-startup and cheapest-total cases, ie, for each
 * interesting ordering, collect all the cheapest startup subpaths and all the
 * cheapest total paths, and build a suitable path for each case.
2. The function does not handle the case where the paths in
total_subpaths and fractional_subpaths are identical.  This is not a
rare scenario, and as a result, it could create two exactly identical
ordered append paths.
3. The comment for startup_neq_total is also out of date, since we may
call create_append_path(), not just create_merge_append_path(), to
generate ordered append paths.
Here is a WIP patch to address these issues.
- Richard