Skip site navigation (1) Skip section navigation (2)

Re: LIKE, leading percent, bind parameters and indexes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Rodrigo Hjort" <rodrigo(dot)hjort(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, "Rodrigo Hjort" <rhjort(at)celepar(dot)pr(dot)gov(dot)br>
Subject: Re: LIKE, leading percent, bind parameters and indexes
Date: 2006-05-24 02:55:23
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
"Rodrigo Hjort" <rodrigo(dot)hjort(at)gmail(dot)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

In response to


pgsql-hackers by date

Next:From: Tom LaneDate: 2006-05-24 02:58:42
Subject: Re: Why is CVS server so slow?
Previous:From: max.polettoDate: 2006-05-24 02:13:11
Subject: Re: problem with PQsendQuery/PQgetResult and COPY FROM statement

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group