Re: MergeAppend could consider sorting cheapest child path

From: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>
To: Andy Fan <zhihuifan1213(at)163(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: MergeAppend could consider sorting cheapest child path
Date: 2025-03-28 08:19:30
Message-ID: 242cc7689213c0e7fafc7cd1add79b4d@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andy Fan писал(а) 2024-10-17 03:33:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
>
>> Is this still being considered?
>
> I'd +1 on this feature. I guess this would be more useful on parallel
> case, where the Sort can be pushed down to parallel worker, and in the
> distributed database case, where the Sort can be pushed down to
> multiple
> nodes, at the result, the leader just do the merge works.
>
> At the high level implementaion, sorting *cheapest* child path looks
> doesn't add too much overhead on the planning effort.

Hi.

I've updated patch. One more interesting case which we found - when
fractional path is selected, it still can be more expensive than sorted
cheapest total path (as we look only on indexes whith necessary
pathkeys, not on indexes which allow efficiently fetch data).
So far couldn't find artificial example, but we've seen inadequate index
selection due to this issue - instead of using index suited for filters
in where, index, suitable for sorting was selected as one having the
cheapest fractional cost.
--
Best regards,
Alexander Pyhalov,
Postgres Professional

Attachment Content-Type Size
v2-0001-MergeAppend-could-consider-using-sorted-best-path.patch text/x-diff 22.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Filip Janus 2025-03-28 08:23:13 Re: Proposal: Adding compression of temporary files
Previous Message Peter Eisentraut 2025-03-28 08:13:54 Re: Thread-safe nl_langinfo() and localeconv()