Re: BUG #17564: Planner bug in combination of generate_series(), unnest() and ORDER BY

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Martijn van Oosterhout <kleptog(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17564: Planner bug in combination of generate_series(), unnest() and ORDER BY
Date: 2022-08-04 01:05:13
Message-ID: CAMbWs4_W70RK77_j+_QzYAey2oQoxa8pwb0rp8KCeeH4bt5Jzg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Aug 3, 2022 at 10:56 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> > On Tue, Aug 2, 2022 at 4:50 PM Martijn van Oosterhout <kleptog(at)gmail(dot)com
> >
> > wrote:
> >> Now it's morning I've thought of a way to reproduce it more easily, see
> >> the attached script.
>
> > Thanks for the report! I can reproduce it on HEAD.
>
> FWIW, this reproduces the bug for me in v13 and v14, but not v15 or HEAD.
> While the method to fix the bug seems clear enough, it doesn't seem
> like we have a test case that's stable enough to be worth anything
> as a regression test. Hmmm...

I'm reproducing this bug in HEAD with the repro given by Martijn, but
with some additional GUC sets:

set enable_hashjoin to off;
set enable_mergejoin to off;
set enable_indexscan to off;
set enable_bitmapscan to off;

When building access paths for base rel 'results', we would generate
Gather Merge on top of its partial path. The key point to reproduce this
bug is how to make this Gather Merge path win in the final plan.

Another way to reproduce this bug in HEAD is to manually hack the cost
of this Gather Merge path to zero with gdb, so that this bug can be
reproduced even with hashjoin.

Thanks
Richard

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2022-08-04 01:55:34 Re: BUG #17564: Planner bug in combination of generate_series(), unnest() and ORDER BY
Previous Message Tom Lane 2022-08-03 21:53:30 Re: BUG #17564: Planner bug in combination of generate_series(), unnest() and ORDER BY