pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrei Lepikhov <lepihov@gmail.com>
To: Tender Wang <tndrwang@gmail.com>
Cc: Richard Guo <guofenglinux@gmail.com>
Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org, Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
Date: Fri, 11 Oct 2024 09:43:52 +0700
Message-ID: <8a09d059-8bcf-48de-8c8e-771d8221091c@gmail.com> (raw)
In-Reply-To: <8026fe90-e661-4448-b9cc-bcbb65629b7b@gmail.com>
References: <18652-deaa782ebcca85d1@postgresql.org>
	<2527690.1728510183@sss.pgh.pa.us>
	<CAMbWs49Pcnm_cX=7azYY9d8+qRrOOKDjJDCa0KGRk9kWWMOz3A@mail.gmail.com>
	<ea7e53bf-5aad-4a0a-8f73-a21dd8f6969b@gmail.com>
	<CAHewXNmFmXFxK7bsgAhqv_ToGxK4y7niNVL3GAzgWEOKuiAg5w@mail.gmail.com>
	<8026fe90-e661-4448-b9cc-bcbb65629b7b@gmail.com>

On 10/10/24 17:23, Andrei Lepikhov wrote:
> On 10/10/24 16:02, Tender Wang wrote:
>>
>>
>> Andrei Lepikhov <lepihov@gmail.com <mailto:lepihov@gmail.com>> 于2024 
>> 年      > I think this is because find_computable_ec_member() only 
>> tries to
>>      > match Vars.  Maybe we should teach it to also match OpExprs?
>>     Looking into that case, I don't understand only one thing:
>>     generate_orderedappend_paths decided to try MergeAppend; the
>>     create_append_path routine added the Sort cost,  but the Sort node
>>     itself wasn't added. Maybe the origin problem is the lack of
>>     feasibility
>>     examinations?
>>
>>
>> Yeah, I'm also curious why only cost Sort but not adding Sort node in 
>> create_merge_append_path().
>> The comments say that " We'll need to insert a Sort node, so include 
>> cost for that".  Does another place
>> insert the Sort node?
> Before inserting the Sort node, we must identify the column 
> corresponding to each path key. And here is the problem: IndexScan has 
> two elements in the target list, but SeqScan has only one. It already 
> looks strange to me. How do we UNION two sources with different numbers 
> of resulting columns? It seems to me we have a bug under the Append node.Sorry for the mess: my sentence is totally wrong: it is the MergeAppend 
node with two elements in the target list (the second one is resjunk). I 
think I should research the logic of how append arranges its pathkeys 
beforehand.

-- 
regards, Andrei Lepikhov






view thread (18+ messages)  latest in thread

Message-ID: <8a09d059-8bcf-48de-8c8e-771d8221091c@gmail.com>
Permalink:  ../8a09d059-8bcf-48de-8c8e-771d8221091c@gmail.com/
Also on:    postgresql.org/message-id/8a09d059-8bcf-48de-8c8e-771d8221091c@gmail.com

 · 

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: lepihov@gmail.com, tndrwang@gmail.com, guofenglinux@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
  In-Reply-To: <8a09d059-8bcf-48de-8c8e-771d8221091c@gmail.com>

* 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