Re: How to observe plan_cache_mode transition from custom to generic plan?

From: Mladen Gogala <gogala(dot)mladen(at)gmail(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: How to observe plan_cache_mode transition from custom to generic plan?
Date: 2021-09-06 07:07:16
Message-ID: 052c4c64-cd0e-9e14-ae9d-ca0e553a3bbf@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2021-09-06 07:16:18 Re: How to observe plan_cache_mode transition from custom to generic plan?
Previous Message Laurenz Albe 2021-09-06 06:26:18 Re: How to observe plan_cache_mode transition from custom to generic plan?