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

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Richard Guo <guofenglinux(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Reordering DISTINCT keys to match input path's pathkeys
Date: 2024-01-23 08:04:22
Message-ID: 189a62747b5a89137b5ecd5105d03847c82c86f8.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2024-01-23 at 13:55 +0800, Richard Guo wrote:
> Similar to what we did to GROUP BY keys in 0452b461bc, I think we can do
> the same to DISTINCT keys, i.e. reordering DISTINCT keys to match input
> path's pathkeys, which can help reduce cost by avoiding unnecessary
> re-sort, or allowing us to use incremental-sort to save efforts.
>
> Attached is a patch for this optimization.  Any thoughts?

I didn't scrutinize the code, but that sounds like a fine optimization.

Yours,
Laurenz Albe

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2024-01-23 08:07:36 Re: Test slots invalidations in 035_standby_logical_decoding.pl only if dead rows are removed
Previous Message Masahiko Sawada 2024-01-23 07:48:25 Re: [PoC] Improve dead tuple storage for lazy vacuum