Re: MergeAppend could consider sorting cheapest child path

From: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>
To: Andrei Lepikhov <lepihov(at)gmail(dot)com>
Cc: Andy Fan <zhihuifan1213(at)163(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Nikita Malakhov <HukuToc(at)gmail(dot)com>
Subject: Re: MergeAppend could consider sorting cheapest child path
Date: 2025-05-07 06:57:16
Message-ID: b1a19522b5f04e9c81495d06f5925d24@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrei Lepikhov писал(а) 2025-05-07 08:02:
> On 5/5/2025 15:56, Alexander Pyhalov wrote:
>> Andrei Lepikhov писал(а) 2025-05-05 14:38:
>> Also logic a bit differs if path is NULL. In
>> get_cheapest_path_for_pathkeys_ext() we explicitly check for path
>> being NULL, in get_cheapest_fractional_path_for_pathkeys_ext() only
>> after calculating sort cost.
>>
>> I've tried to fix comments a bit and unified functions definitions.
> Generally seems ok, I'm not a native speaker to judge the comments.
> But:
> if (base_path && path != base_path)
>
> What is the case in your mind where the base_path pointer still may be
> null at that point?

Hi.

It seems if some childrel doesn't have valid pathlist, subpaths_valid
would be false in add_paths_to_append_rel()
and generate_orderedappend_paths() will not be called. So when we
iterate over live_childrels,
all of them will have cheapest_total path. This is why we can assert
that base_path is not NULL.
--
Best regards,
Alexander Pyhalov,
Postgres Professional

Attachment Content-Type Size
v5-0001-Consider-explicit-sort-of-the-MergeAppend-subpath.patch text/x-diff 29.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-05-07 06:59:10 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Previous Message Richard Guo 2025-05-07 06:55:51 Re: Reduce "Var IS [NOT] NULL" quals during constant folding