pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: pgsql-performance@postgresql.org
Cc: Andrus <eetasoft@online.ee>
Subject: Re: How to force Postgres to use index on ILIKE
Date: Mon, 5 Jun 2006 14:26:56 -0700
Message-ID: <200606051426.56789.josh@agliodbs.com> (raw)
In-Reply-To: <e620mg$15jr$1@news.hub.org>
References: <e620mg$15jr$1@news.hub.org>

Andrus,

> SELECT toode, nimetus
> FROM toode
> WHERE toode      ILIKE  'x10%' ESCAPE '!'
> ORDER BY UPPER(toode     ),nimetus  LIMIT 100
>
> runs 1 minute in first time for small table size.
>
> Toode field type is CHAR(20)

1) why are you using CHAR and not VARCHAR or TEXT?   CHAR will give you 
problems using an index, period.

2) You can't use an index on ILIKE.  You can, however, use an index on 
lower(field) if your query is properly phrased and if you've created an 
expression index on lower(field).

-- 
--Josh

Josh Berkus
PostgreSQL @ Sun
San Francisco



view thread (4+ messages)  latest in thread

Message-ID: <200606051426.56789.josh@agliodbs.com>
Permalink:  ../200606051426.56789.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200606051426.56789.josh@agliodbs.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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: josh@agliodbs.com, eetasoft@online.ee
  Subject: Re: How to force Postgres to use index on ILIKE
  In-Reply-To: <200606051426.56789.josh@agliodbs.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