pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brendan Duddridge <brendan@clickspace.com>
To: Ibrahim Tekin <itekin@gmail.com>
Cc: Scott Marlowe <smarlowe@g2switchworks.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: LIKE query on indexes
Date: Wed, 22 Feb 2006 08:48:43 -0700
Message-ID: <78873B6F-1572-467C-8F98-9715FC8AC4AC@clickspace.com> (raw)
In-Reply-To: <e4dcba670602211228u2900be53mb0de28bd5e78b93f@mail.gmail.com>
References: <e4dcba670602210757n2caf7c15t2a93353c9081c51f@mail.gmail.com>
	<1140538679.5777.3.camel@state.g2switchworks.com>
	<20060221163416.GC6541@surnet.cl>
	<e4dcba670602211228u2900be53mb0de28bd5e78b93f@mail.gmail.com>

Hi,

Can this technique work with case insensitive ILIKE?

It didn't seem to use the index when I used ILIKE instead of LIKE.

Thanks,

____________________________________________________________________
Brendan Duddridge | CTO | 403-277-5591 x24 |  brendan@clickspace.com

ClickSpace Interactive Inc.
Suite L100, 239 - 10th Ave. SE
Calgary, AB  T2G 0V9

http://www.clickspace.com

On Feb 21, 2006, at 1:28 PM, Ibrahim Tekin wrote:

> this trick did the job.
> thanks.
>
> On 2/21/06, Alvaro Herrera <alvherre@commandprompt.com> wrote:
> Scott Marlowe wrote:
> > On Tue, 2006-02-21 at 09:57, Ibrahim Tekin wrote:
> > > hi,
> > > i have btree index on a text type field. i want see rows which  
> starts
> > > with certain characters on that field. so i write a query like  
> this:
> > >
> > > SELECT * FROM mytable WHERE myfield LIKE 'john%'
> > >
> > > since this condition is from start of the field, query planner  
> should
> > > use index to find such elements but explain command shows me it  
> will
> > > do a sequential scan.
> > >
> > > is this lack of a feature or i am wrong somewhere?
> >
> > This is an artifact of how PostgreSQL handles locales other than  
> ASCII.
> >
> > If you want such a query to use an index, you need to back up your
> > database, and re-initdb with --locale=C as an argument.
>
> ... or you can choose to create an index with the text_pattern_ops
> operator class, which would be used in a LIKE constraint regardless of
> locale.
>
> http://www.postgresql.org/docs/8.1/static/indexes-opclass.html
>
> --
> Alvaro Herrera                                 http:// 
> www.CommandPrompt.com/
> The PostgreSQL Company - Command Prompt, Inc.
>

Attachments:

  smime.p7s (application/pkcs7-signature, 2.3K) download

view thread (9+ messages)  latest in thread

Message-ID: <78873B6F-1572-467C-8F98-9715FC8AC4AC@clickspace.com>
Permalink:  ../78873B6F-1572-467C-8F98-9715FC8AC4AC@clickspace.com/
Also on:    postgresql.org/message-id/78873B6F-1572-467C-8F98-9715FC8AC4AC@clickspace.com

 · 

reply

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-performance@postgresql.org
  Cc: brendan@clickspace.com, itekin@gmail.com, smarlowe@g2switchworks.com
  Subject: Re: LIKE query on indexes
  In-Reply-To: <78873B6F-1572-467C-8F98-9715FC8AC4AC@clickspace.com>
  References: <e4dcba670602210757n2caf7c15t2a93353c9081c51f@mail.gmail.com> <1140538679.5777.3.camel@state.g2switchworks.com> <20060221163416.GC6541@surnet.cl> <e4dcba670602211228u2900be53mb0de28bd5e78b93f@mail.gmail.com> <78873B6F-1572-467C-8F98-9715FC8AC4AC@clickspace.com>

* 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