Re: Does PostgreSQL do bind-peeking? Is `col like '%'` optimized-away by the planner? - Mailing list pgsql-general

From David G. Johnston
Subject Re: Does PostgreSQL do bind-peeking? Is `col like '%'` optimized-away by the planner?
Date
Msg-id CAKFQuwZA6iKQOQWSDu8MY2NCYhB0RhQpmRCKakLUsVhwAEOxfg@mail.gmail.com
Whole thread Raw
In response to Does PostgreSQL do bind-peeking? Is `col like '%'` optimized-away by the planner?  (Dominique Devienne <ddevienne@gmail.com>)
List pgsql-general
On Fri, Jan 21, 2022 at 9:36 AM Dominique Devienne <ddevienne@gmail.com> wrote:

for the various cases of empty argN strings, or does the planner do
*bind-peeking*, and thus a single prepared statement would do the job,
and still have different plans used depending on the actual binds?

I'm assuming PostgreSQL does bind-peeking like Oracle, but I don't
know, and I've never read anything yet about that.


A prepared statement either generates a custom plan and, as a side-effect, does bind-peeking, or it uses the single prepared plan it has established and executes that.  It doesn't use bind-peeking to decide among multiple saved prepared plans. There is more to it than that, like a 5 custom plan threshold before abandoning bind-peeking (I think I got that right...).

David J.

pgsql-general by date:

Previous
From: Dominique Devienne
Date:
Subject: Does PostgreSQL do bind-peeking? Is `col like '%'` optimized-away by the planner?
Next
From: Guillaume Lelarge
Date:
Subject: Re: Using a different column name in a foreign table