Re: Speeding up LIKE with placeholders? - Mailing list pgsql-general

From Tom Lane
Subject Re: Speeding up LIKE with placeholders?
Date
Msg-id 3576.1094855601@sss.pgh.pa.us
Whole thread Raw
In response to Re: Speeding up LIKE with placeholders?  (Dan Sugalski <dan@sidhe.org>)
Responses Re: Speeding up LIKE with placeholders?
List pgsql-general
Dan Sugalski <dan@sidhe.org> writes:
> Since the only difference in this case is that the parameters are
> pulled out for transport rather than being in band (a
> properly-escaped string substitution could turn this case from a
> PQexecParams call into a PQexec call) I was thinking the thing to do
> would be to either teach the planner to look in the parameter list
> when it gets handed $xxx variables, or have the back-end do the
> substitution to the SQL before handing the code to the planner.

This has already been considered and rejected.  Oliver Jowett did the
part that is safe, which is to use the parameter values for estimation
purposes in other contexts, but pre-substituting a parameter value for
LIKE calls the mere correctness of the plan into question.

What it would take to make it workable is a change in the semantics of
the v3 protocol messages, such that there is no re-use of a plan.  That,
no one is up for quite yet, when we just hacked the protocol last year ...

            regards, tom lane

pgsql-general by date:

Previous
From: Kevin Barnard
Date:
Subject: Re: What is the postgres version of mysql's "ON DUPLICATE KEY"
Next
From: Dan Sugalski
Date:
Subject: Re: Speeding up LIKE with placeholders?