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

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Richard Guo <guofenglinux(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-14 12:01:49
Message-ID: e7a4d391-bfc5-4226-88fa-9f35c1d2fbdc@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/14/24 08:09, Richard Guo wrote:
> On Wed, Nov 13, 2024 at 7:36 PM Andrei Lepikhov <lepihov(at)gmail(dot)com> wrote:
>> On 11/13/24 13:49, Richard Guo wrote:
>> In thread [1], I try to add one more strategy that minimises the number
>> of comparison operator calls. It seems that it would work the same way
>> with the DISTINCT statement. Do you think it make sense in general and
>> can be a possible direction of improvement for the current patch?
>
> I haven’t had a chance to follow that thread. From a quick look at
> that patch, it seems to improve the general costing logic for sorting.
> If that’s the case, I think it would be beneficial in the areas where
> we use cost_sort(), including in this patch.
Yes, the core of the discussion is cost calculation. It is a base for
the final patch that adds a grouping strategy, according to which it may
be profitable to put the column with max distinct value at the first
position to make sorting less expensive. I think it makes sense to do
the same in this DISTINCT feature, too (as a further improvement, of
course).

>> disable features during severe slowdowns or bugs. It might make sense to
>> group them into a single 'Clause Reordering' parameter.
> code. If these GUCs are mainly for debugging, I think it's better to
> keep them separate so that we can debug each optimization individually.
Ok.
See minor changes I propose in the attachment.

--
regards, Andrei Lepikhov

Attachment Content-Type Size
minor-fix.diff text/x-patch 3.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2024-11-14 12:11:43 Re: Add html-serve target to autotools and meson
Previous Message Bertrand Drouvot 2024-11-14 11:58:01 Re: define pg_structiszero(addr, s, r)