Re: BUG #19102: Assertion failure in generate_orderedappend_paths with aggregate pushdown

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, akorotkov(at)postgresql(dot)org
Subject: Re: BUG #19102: Assertion failure in generate_orderedappend_paths with aggregate pushdown
Date: 2025-11-03 13:09:44
Message-ID: CAMbWs4-OYsgA75tGGiBARt87G0y_z_GBTSLrzudcJxAzndYkYw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Nov 3, 2025 at 7:09 PM Richard Guo <guofenglinux(at)gmail(dot)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

Attachment Content-Type Size
v1-0001-Fix-generate_orderedappend_paths.patch application/octet-stream 4.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kumaresan Balakrishnan 2025-11-03 17:10:23 CREATE TABLE ... LIKE INCLUDING ALL does not create new sequences for serial columns
Previous Message Richard Guo 2025-11-03 10:09:25 Re: BUG #19102: Assertion failure in generate_orderedappend_paths with aggregate pushdown