pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrei Lepikhov <lepihov@gmail.com>
Cc: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
Date: Sat, 12 Oct 2024 12:13:51 +0800
Message-ID: <CAMbWs48t0LBsPf4bZ9UdGousuTNmrauD_01NrauRFXTrwt++Jg@mail.gmail.com> (raw)
In-Reply-To: <3001952.1728680364@sss.pgh.pa.us>
References: <18652-deaa782ebcca85d1@postgresql.org>
	<2527690.1728510183@sss.pgh.pa.us>
	<CAMbWs49Pcnm_cX=7azYY9d8+qRrOOKDjJDCa0KGRk9kWWMOz3A@mail.gmail.com>
	<40c8a5c2-0040-4fe6-ab11-6dca23353a07@gmail.com>
	<3001952.1728680364@sss.pgh.pa.us>

On Sat, Oct 12, 2024 at 4:59 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> This means that it will work so long as all of the Vars needed by the
> EC member expression are available from the plan node's input, which
> they surely are if they are referenced in the existing tlist.  That
> is, even if we wanted to compute "t2.i + 2" it'd be fine.
>
> (This would fall down perhaps if there are volatile functions in
> the sort expression, but I believe we already reject using volatile
> expressions for merge append, so it's not a problem.)
>
> So I conclude that Andrei's patch will fix it, although I don't like
> the way that that requires (potentially) multiple re-executions of
> pull_var_clause.  I think we should refactor the code to avoid that,
> which actually ends up being less code, as in the attached draft.

+1.  I think it's conceptually correct that if 'Var_A + 2' is
computable in a plan node's targetlist, then 'Var_A + 1' must be also
computable in the same targetlist.

Thanks
Richard





view thread (18+ messages)  latest in thread

Message-ID: <CAMbWs48t0LBsPf4bZ9UdGousuTNmrauD_01NrauRFXTrwt++Jg@mail.gmail.com>
Permalink:  ../CAMbWs48t0LBsPf4bZ9UdGousuTNmrauD_01NrauRFXTrwt++Jg@mail.gmail.com/
Also on:    postgresql.org/message-id/CAMbWs48t0LBsPf4bZ9UdGousuTNmrauD_01NrauRFXTrwt++Jg@mail.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: guofenglinux@gmail.com, tgl@sss.pgh.pa.us, lepihov@gmail.com, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
  In-Reply-To: <CAMbWs48t0LBsPf4bZ9UdGousuTNmrauD_01NrauRFXTrwt++Jg@mail.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