Re: Want function to be called only once in query

2021-09-16 Thread Steve Pritchard
> Add the MATERIALIZED keyword to the WITH statement Many thanks Jim, that's just what I needed - that does the trick. It's hard to keep abreast of these SQL changes. Thank goodness for mailing lists! Steve On Thu, 16 Sept 2021 at 11:56, Jim Mlodgenski wrote: > On Thu, Sep 16, 2021 at 4:51 AM

Re: Want function to be called only once in query

2021-09-16 Thread Jim Mlodgenski
On Thu, Sep 16, 2021 at 4:51 AM Steve Pritchard wrote: > > I have a PL/pgSQL function that I want to call within a query, but the > function is fairly expensive to execute so I only want it executed once > within the query. However the planner seems to reorganize my query so that it > calls the

Want function to be called only once in query

2021-09-16 Thread Steve Pritchard
I have a PL/pgSQL function that I want to call within a query, but the function is fairly expensive to execute so I only want it executed once within the query. However the planner seems to reorganize my query so that it calls the function for every row. We were previously on Pg 9.6 and this wasn'

Re: Postgres chooses slow query plan from time to time

2021-09-16 Thread Kristjan Mustkivi
Understood. Thank you so much for looking into this! Best regards, Kristjan On Wed, Sep 15, 2021 at 5:34 PM Tom Lane wrote: > > Kristjan Mustkivi writes: > > On Wed, Sep 15, 2021 at 3:16 PM Tom Lane wrote: > >> Note the lack of any visible cast on the varchar column, in each one of > >> thes