Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index - Mailing list pgsql-bugs

From Richard Guo
Subject Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
Date
Msg-id CAMbWs48t0LBsPf4bZ9UdGousuTNmrauD_01NrauRFXTrwt++Jg@mail.gmail.com
Whole thread Raw
In response to Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
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



pgsql-bugs by date:

Previous
From: Andrei Lepikhov
Date:
Subject: Re: Question of Parallel Hash Join on TPC-H Benchmark
Next
From: Sandeep Thakkar
Date:
Subject: Re: BUG #18646: The problem with the installer