david.g.johnston@xxxxxxxxx wrote: Thank you very much for the doc pointers, David. I believe that I have all I need, now. I understood already that "giving permission to cache" doesn't mean that PG will actually cache anything. I wanted only to find a compelling example of how lying when you mark a function "immutable" can bring wring results. I think that this is sufficient: set x.a = '13'; create function dishonestly_marked_immutable(i in int) returns int immutable language plpgsql as $body$ begin return i*(current_setting('x.a')::int); end; $body$; prepare q as select dishonestly_marked_immutable(2) as "With actual '2'", dishonestly_marked_immutable(3) as "With actual '3'"; execute q; set x.a = '19'; execute q; ------------------<< Produces the stale "26 | 39". discard plans; execute q; ------------------<< Now produces the correct "38 | 57" |