Re: Volatile functions under Memoize node - Mailing list pgsql-bugs

From David Rowley
Subject Re: Volatile functions under Memoize node
Date
Msg-id CAApHDvopmkAOecfQczbOvkVvo=OK89rABXujVYsFevsk77Dqdw@mail.gmail.com
Whole thread Raw
In response to Volatile functions under Memoize node  (Andrei Lepikhov <lepihov@gmail.com>)
Responses Re: Volatile functions under Memoize node
Re: Volatile functions under Memoize node
List pgsql-bugs
On Fri, 20 Sept 2024 at 04:47, Andrei Lepikhov <lepihov@gmail.com> wrote:
> Excuse me if I made noise in vain. After discovering the limits of the
> Memoize node, I realized that volatile functions are allowed under the
> Memoize. Example:

I don't think we're particularly consistent about the number of
evaluations of volatile functions in general.

Here's something crafted up without Memoize:

create function volatilefunc(p int) returns int as $$
begin
raise notice '%', p;
return p;
end;
$$ language plpgsql volatile;

explain analyze select * from (values(1),(2)) t1(v) where t1.v
in(select t2.v from (values(1),(2)) t2(v) inner join (values(1),(2))
t3(v) on t2.v = volatilefunc(t3.v));

Normally:
NOTICE:  1
NOTICE:  2
NOTICE:  1
NOTICE:  2

But:
set enable_hashagg = 0;
set enable_hashjoin = 0;
set enable_material = 0;
set enable_sort = 0;

gives:
NOTICE:  1
NOTICE:  1
NOTICE:  2
NOTICE:  1
NOTICE:  2

I'm not sure if it's a good idea to penalise your case when we're not
all that consistent to start with.  Is this causing some sort of
breakage?

David



pgsql-bugs by date:

Previous
From: Thomas Munro
Date:
Subject: Re: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607
Next
From: Andrei Lepikhov
Date:
Subject: Re: Volatile functions under Memoize node