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

Re: How to boost performance of ilike queries ?

From: Antony Paul <antonypaul24(at)gmail(dot)com>
To: Russell Smith <mr-russ(at)pws(dot)com(dot)au>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: How to boost performance of ilike queries ?
Date: 2005-01-25 10:09:56
Message-ID: 2989532e05012502092288a062@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
Actually the query is created like this.
User enters the query in a user interface. User can type any character
in the query criteria. ie. % and _ can be at any place. User have the
freedom to choose query columns as well. The query is agianst a single
table .

rgds
Antony Paul


On Tue, 25 Jan 2005 19:49:12 +1100, Russell Smith <mr-russ(at)pws(dot)com(dot)au> wrote:
> On Tue, 25 Jan 2005 07:23 pm, Antony Paul wrote:
> > Creating an index and using lower(column) does not change the explain
> > plan estimates.
> > It seems that it is not using index for like or ilike queries
> > irrespective of whether it have a pattern matching character in it or
> > not. (using PostgreSQL 7.3.3)
> >
> > On googling I found this thread
> >
> > http://archives.postgresql.org/pgsql-sql/2004-11/msg00285.php
> >
> > It says that index is not used if the search string begins with a % symbol.
> 
> What exactly are the type of like queries you are going?  there is a solution
> for having the % at the start, but you can win everyway.
> 
> >
> > rgds
> > Antony Paul
> >
> > On Mon, 24 Jan 2005 20:58:54 +1100, Russell Smith <mr-russ(at)pws(dot)com(dot)au> wrote:
> > > On Mon, 24 Jan 2005 08:18 pm, Antony Paul wrote:
> > > > Hi,
> > > >     I have a query which is executed using ilike. The query values are
> > > > received from user and it is executed using PreparedStatement.
> > > > Currently all queries are executed as it is using iilike irrespective
> > > > of whether it have a pattern matching character or not. Can using =
> > > > instead of ilike boot performance ?.  If creating index can help then
> > > > how the index should be created on lower case or uppercase ?.
> > > >
> > > It depends on the type of queries you are doing.
> > >
> > > changing it to something like  lower(column) like lower('text%'), and
> > > creating an index on lower(column) will give you much better performance.
> > >
> > > If you have % in the middle of the query, it will still be slow, but I assume that is not
> > > the general case.
> > >
> > > I am not sure what the effect of it being prepared will be, however I've had much success
> > > with the method above without the queries being prepared.  Others may be able to offer advice
> > > about if prepare will effect it.
> > >
> > > Regards
> > >
> > > Russell Smith
> > >
> >
> >
>

In response to

pgsql-performance by date

Next:From: Hannu KrosingDate: 2005-01-25 10:42:47
Subject: Re: PostgreSQL clustering VS MySQL clustering
Previous:From: Ragnar HafstaĆ°Date: 2005-01-25 09:52:06
Subject: Re: PgPool changes WAS: PostgreSQL clustering VS MySQL

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