Re: Fwd: Planning time is time-consuming

Laurenz Albe <laurenz.albe@cybertec.at>

From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Mikhail Balayan <mv.balayan@gmail.com>, pgsql-performance@postgresql.org, Anupam b <abordia99@hotmail.com>
Date: 2023-09-11T08:13:26Z
Lists: pgsql-performance
On Mon, 2023-09-11 at 12:57 +0800, Mikhail Balayan wrote:
> Thanks for the idea. I was surprised to find that this is not the way it works and the planning time remains the same.

To benefit from the speed gains of a prepared statement, you'd have to execute it
at least seven times.  If a generic plan is used (which should happen), you will
see $1 instead of the literal argument in the execution plan.

Prepared statements are probably your best bet.

Yours,
Laurenz Albe