Re: thousands of CachedPlan entry per backend

Laurenz Albe <laurenz.albe@cybertec.at>

From: Laurenz Albe <laurenz.albe@cybertec.at>
To: "James Pang (chaolpan)" <chaolpan@cisco.com>, Pavel Stehule <pavel.stehule@gmail.com>
Cc: "pgsql-performance@lists.postgresql.org" <pgsql-performance@lists.postgresql.org>
Date: 2023-06-01T12:48:23Z
Lists: pgsql-performance
On Thu, 2023-06-01 at 08:50 +0000, James Pang (chaolpan) wrote:
> we found thousands of cached plan , since JDBC driver only allow max 256 cached
> prepared statements, how backend cache so many sql plans. If we have one function,
> when application call that function will make backend to cache  every SQL statement
> plan in that function too?   and for table triggers, have similar caching behavior ?

Yes, as long as the functions are written in PL/pgSQL.
It only affects static SQL, that is, nothing that is run with EXECUTE.

Yours,
Laurenz Albe