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

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Dominique Devienne <ddevienne(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Does PostgreSQL do bind-peeking? Is `col like '%'` optimized-away by the planner?
Date: 2022-01-21 16:44:30
Message-ID: CAKFQuwZA6iKQOQWSDu8MY2NCYhB0RhQpmRCKakLUsVhwAEOxfg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jan 21, 2022 at 9:36 AM Dominique Devienne <ddevienne(at)gmail(dot)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.

In response to

Browse pgsql-general by date

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