Re: Check volatile functions in ppi_clauses for memoize node

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Check volatile functions in ppi_clauses for memoize node
Date: 2023-08-08 00:54:10
Message-ID: CAMbWs49OsS+T4XepK9iV9YuQKYzgWF0QY6DA9iPb40fKr4n0gQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 7, 2023 at 6:19 PM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:

> On Fri, 4 Aug 2023 at 22:26, Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> > explain (costs off)
> > select * from t t1 left join lateral
> > (select t1.a as t1a, t2.a as t2a from t t2) s
> > on t1.a = s.t2a + random();
> > QUERY PLAN
> > -----------------------------------------------
> > Nested Loop Left Join
> > -> Seq Scan on t t1
> > -> Memoize
> > Cache Key: t1.a
> > Cache Mode: binary
> > -> Seq Scan on t t2
> > Filter: (t1.a = (a + random()))
> > (7 rows)
> >
> > According to the theory we should not use memoize node for this query
> > because of the volatile function in the inner side. So propose a patch
> > to fix that.
>
> Thanks for the patch. I've pushed a variation of it.
>
> I didn't really see the need to make a single list with all the
> RestrictInfos. It seems fine just to write code and loop over the
> ppi_clauses checking for volatility.

That looks good. Thanks for pushing it!

Thanks
Richard

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-08-08 01:05:09 Re: Support to define custom wait events for extensions
Previous Message Yugo NAGATA 2023-08-08 00:47:47 Re: pgbench: allow to exit immediately when any client is aborted