Re: LIKE, leading percent, bind parameters and indexes - Mailing list pgsql-hackers

From Tom Lane
Subject Re: LIKE, leading percent, bind parameters and indexes
Date
Msg-id 24934.1148439323@sss.pgh.pa.us
Whole thread Raw
In response to LIKE, leading percent, bind parameters and indexes  ("Rodrigo Hjort" <rodrigo.hjort@gmail.com>)
Responses Re: LIKE, leading percent, bind parameters and indexes
List pgsql-hackers
"Rodrigo Hjort" <rodrigo.hjort@gmail.com> writes:
> What happens is that only the "004" block uses the index! The "002" code,
> which also has no leading percent, does a sequential scan. The difference
> between them is that "002" uses bind parameters.

Yeah.  The LIKE index optimization depends on seeing a constant LIKE
pattern at plan time --- otherwise the planner doesn't know what
indexscan parameters to generate.  So a bound-parameter query loses.

Ideas for improving this situation are welcome ... it's not an easy
problem ...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Why is CVS server so slow?
Next
From: Tom Lane
Date:
Subject: Re: Why is CVS server so slow?