Avoid creating duplicate ordered append paths
authorRichard Guo <rguo@postgresql.org>
Wed, 5 Nov 2025 09:10:54 +0000 (18:10 +0900)
committerRichard Guo <rguo@postgresql.org>
Wed, 5 Nov 2025 09:10:54 +0000 (18:10 +0900)
commit0ea5eee37606386150aa8317184617e1d5d34565
tree4a4a11595db2e554055c55ab104729a6e926ef68
parentc1777f2d6d43adf9bc65da3e44a3a5ad2cbfa86d
Avoid creating duplicate ordered append paths

In generate_orderedappend_paths(), the function does not handle the
case where the paths in total_subpaths and fractional_subpaths are
identical.  This situation is not uncommon, and as a result, it may
generate two exactly identical ordered append paths.

Fix by checking whether total_subpaths and fractional_subpaths contain
the same paths, and skipping creation of the ordered append path for
the fractional case when they are identical.

Given the lack of field complaints about this, I'm a bit hesitant to
back-patch, but let's clean it up in HEAD.

Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Andrei Lepikhov <lepihov@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Discussion: https://postgr.es/m/CAMbWs4-OYsgA75tGGiBARt87G0y_z_GBTSLrzudcJxAzndYkYw@mail.gmail.com
src/backend/optimizer/path/allpaths.c