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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dominique Devienne <ddevienne(at)gmail(dot)com>
Cc: 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:47:53
Message-ID: 1191689.1642783673@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dominique Devienne <ddevienne(at)gmail(dot)com> writes:
> Will the query planner be able to *peek* into the args, and turn the
> `colN like $N`
> into a no-op?

No. It would not do that even if the pattern were constant '%';
it doesn't know that much about that particular function.

There is a notion of "custom plans" in which parameter values are
inserted as constants, precisely to allow simplifications based on
known constant values. But this particular case isn't implemented.

I am entirely unfamiliar with the terminology "bind-peeking", so
I can't say whether that's effectively the same thing as our
custom plans.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-01-21 16:48:13 Re: Can commands be typed in to view geometry in PgAdmin?
Previous Message Guillaume Lelarge 2022-01-21 16:47:12 Re: Using a different column name in a foreign table