From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dominique Devienne <ddevienne@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Does PostgreSQL do bind-peeking? Is `col like '%'` optimized-away by the planner?
Date: Fri, 21 Jan 2022 11:47:53 -0500
Message-ID: <1191689.1642783673@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFCRh-_3d5M=betpuTgU5JMtDTMbXVGZJYwh+S-k3cMQFqvNug@mail.gmail.com>
References: <CAFCRh-_3d5M=betpuTgU5JMtDTMbXVGZJYwh+S-k3cMQFqvNug@mail.gmail.com>
Dominique Devienne <ddevienne@gmail.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
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: tgl@sss.pgh.pa.us, ddevienne@gmail.com
Subject: Re: Does PostgreSQL do bind-peeking? Is `col like '%'` optimized-away by the planner?
In-Reply-To: <1191689.1642783673@sss.pgh.pa.us>
References: <CAFCRh-_3d5M=betpuTgU5JMtDTMbXVGZJYwh+S-k3cMQFqvNug@mail.gmail.com> <1191689.1642783673@sss.pgh.pa.us>
* 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