scalar plpgsql functions and their stability flags

From: Victor Dobrovolsky <booby(dot)stager(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: scalar plpgsql functions and their stability flags
Date: 2024-05-26 13:20:10
Message-ID: CAJFsatN_5EkCuk8GqUG_1iOD0ON6x4BTeMWU08Jierr5m+GD7Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Good day experts...

Question on scalar plpgsql functions stability flags (immutable, stable)
regarding how it works in sql queries.

It is clear that for immutable/stable functions with constant parameters,
query planner could/should calculate value in a parse time and use it
directly in query, or at least once per query.

But it is unclear for me what exactly should/can happens when parameters
are bounded not to constant values but to query fields.
In such a case there could be some caching mechanics involved for
parameters combinations and result values.
Like building a hash table for that or something similar.

Can someone give me guidance on this matter.
What limits the usefulness of such a mechanism, if it exists.

Thank you.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2024-05-26 14:27:14 Re: scalar plpgsql functions and their stability flags
Previous Message sud 2024-05-26 09:15:50 Re: Long running query causing XID limit breach