Re: Reordering DISTINCT keys to match input path's pathkeys

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Andrei Lepikhov <lepihov(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, David Rowley <dgrowleyml(at)gmail(dot)com>
Subject: Re: Reordering DISTINCT keys to match input path's pathkeys
Date: 2024-11-13 06:49:59
Message-ID: CAMbWs4-SHEBahuQCo7-4yK4=CmEP6jd5RwKbGUB2akFB79mCCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 28, 2024 at 6:15 PM Andrei Lepikhov <lepihov(at)gmail(dot)com> wrote:
> On 6/7/24 16:46, Richard Guo wrote:
> > This patch does not apply any more, so here is a new rebase, with some
> > tweaks to the comments.

> This patch needs a minor rebase again.
> After skimming the code, I want to say that it looks good. But maybe to
> avoid one more *_reordering GUC - it would be better to cover all path
> key reorderings under a single GUC.

Thanks for reviewing this patch. After some consideration, I think
it's not too complex to also apply this optimization to DISTINCT ON.
The parser already ensures that the DISTINCT ON expressions match the
initial ORDER BY expressions; we just need to ensure that the
resulting pathkey list from the reordering matches the original
distinctClause pathkeys, while leaving the remaining pathkeys
unchanged in order. Please see attached.

I'm not sure about merging these two 'reordering' GUCs into one.
While they may look similar, they apply to very different scenarios.
However, I'm open to other suggestions.

Thanks
Richard

Attachment Content-Type Size
v4-0001-Reordering-DISTINCT-keys-to-match-input-path-s-pathkeys.patch application/octet-stream 38.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rahila Syed 2024-11-13 07:30:52 Re: Enhancing Memory Context Statistics Reporting
Previous Message Thomas Munro 2024-11-13 06:46:08 Writing out WAL buffers that are still in flux