From: Mladen Gogala <gogala.mladen@gmail.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to observe plan_cache_mode transition from custom to generic plan?
Date: Mon, 6 Sep 2021 03:07:16 -0400
Message-ID: <052c4c64-cd0e-9e14-ae9d-ca0e553a3bbf@gmail.com> (raw)
In-Reply-To: <3968ca671180b32b8199b2a1c1fbf9a43fa14d60.camel@cybertec.at>
References: <CABR0jERKQzmE7G5nDpHDfA+502OAZaNcYY46KL=w1CtdQ1NcQw@mail.gmail.com>
<0f9c9510-f4f3-0388-b382-36063f0d4e36@gmail.com>
<3968ca671180b32b8199b2a1c1fbf9a43fa14d60.camel@cybertec.at>
On 9/6/21 2:26 AM, Laurenz Albe wrote:
> "Bind variables" just being an Oraclism for parameters, it is*not* a
> mistake to use them in PostgreSQL.
Actually, it is a mistake because they don't give you any performance
benefit and can potentially worsen the performance. There is no cursor
sharing and generic plans can be much worse than "custom" plans,
generated with the actual values. The only reason for using bind
variables/parameters is to protect yourself from SQL injection. Creating
SQL dynamically from input is the recipe for the "little Bobby Tables"
situation: https://xkcd.com/327/
--
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: gogala.mladen@gmail.com, laurenz.albe@cybertec.at
Subject: Re: How to observe plan_cache_mode transition from custom to generic plan?
In-Reply-To: <052c4c64-cd0e-9e14-ae9d-ca0e553a3bbf@gmail.com>
References: <CABR0jERKQzmE7G5nDpHDfA+502OAZaNcYY46KL=w1CtdQ1NcQw@mail.gmail.com> <0f9c9510-f4f3-0388-b382-36063f0d4e36@gmail.com> <3968ca671180b32b8199b2a1c1fbf9a43fa14d60.camel@cybertec.at> <052c4c64-cd0e-9e14-ae9d-ca0e553a3bbf@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox