pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alena Rybakina <a.rybakina@postgrespro.ru>
To: pgsql-bugs@lists.postgresql.org
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: exclusion@gmail.com, Andrei Lepikhov <lepihov@gmail.com>
Cc: Richard Guo <guofenglinux@gmail.com>
Subject: Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
Date: Fri, 11 Oct 2024 13:42:05 +0300
Message-ID: <a6d1779d-6cfb-4adf-8c79-f547af44c239@postgrespro.ru> (raw)
In-Reply-To: <4266190e-a11b-4f0a-b663-e9059aecdc90@postgrespro.ru>
References: <18652-deaa782ebcca85d1@postgresql.org>
	<2527690.1728510183@sss.pgh.pa.us>
	<CAMbWs49Pcnm_cX=7azYY9d8+qRrOOKDjJDCa0KGRk9kWWMOz3A@mail.gmail.com>
	<2572174.1728534842@sss.pgh.pa.us>
	<CAMbWs493zyKNN2nJmYWpcNGn9N+D3D+1qavjFRMvRGR55UWrhA@mail.gmail.com>
	<4266190e-a11b-4f0a-b663-e9059aecdc90@postgrespro.ru>

On 11.10.2024 11:02, Alena Rybakina wrote:
> On 10.10.2024 14:57, Richard Guo wrote:
>> On Thu, Oct 10, 2024 at 12:34 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> So it's specific to MergeAppend and it's been wrong from day zero.
>>> That makes me think it's probably not find_computable_ec_member's
>>> fault directly.  Fixing it there might be the most expedient answer,
>>> but I feel like first we should drill down a bit further to understand
>>> the root problem.  I'm too tired to do more tonight though.
>> Usually a relation's targetlist should include only Vars and PHVs
>> during this phase.  I think this may be the rationale behind
>> find_computable_ec_member matching only Vars and quasi-Vars. However,
>> for a child rel, when we copy the parent's targetlist with appropriate
>> substitution, we may generate arbitrary expressions, such as an OpExpr
>> for 'i + 1' in this case.
>>
>> We have a note in the comments in set_append_rel_size saying that
>>
>> * Code that might be looking at an appendrel child must cope with
>> * such.
>>
>> It seems to me that find_computable_ec_member does not get this memo.
>>
>> Alternatively, can we wrap non-var expressions in a childrel's
>> targetlist into PHVs, so that we do not need special handling for an
>> appendrel child?  I have not tried this though.
>>
> To be honest, looking at the MergeAppend processing plan, it’s not 
> entirely clear to me what the functional difference is between 
> set_rel_pathlist and
>
> find_computable_ec_member. Both prepare pathkeys , but what the first 
> function doesn't do is what the other one needs to do?Could you 
> explain it to me?
>
Sorry, I meant add_child_rel_equivalences function I've just understood 
it. Sorry for noise

-- 
Regards,
Alena Rybakina
Postgres Professional






view thread (18+ messages)  latest in thread

Message-ID: <a6d1779d-6cfb-4adf-8c79-f547af44c239@postgrespro.ru>
Permalink:  ../a6d1779d-6cfb-4adf-8c79-f547af44c239@postgrespro.ru/
Also on:    postgresql.org/message-id/a6d1779d-6cfb-4adf-8c79-f547af44c239@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: a.rybakina@postgrespro.ru, pgsql-bugs@lists.postgresql.org, tgl@sss.pgh.pa.us, lepihov@gmail.com, guofenglinux@gmail.com
  Subject: Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
  In-Reply-To: <a6d1779d-6cfb-4adf-8c79-f547af44c239@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox