pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Alex Kretschmer <a_kretschmer@gmx.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: postgres index on ILIKE
Date: Mon, 29 Sep 2003 10:09:31 -0700
Message-ID: <200309291009.31470.josh@agliodbs.com> (raw)
In-Reply-To: <3F7824A8.2010704@gmx.de>
References: <3F7824A8.2010704@gmx.de>

Alex,

> mydb=# explain select filename from neighbors where filename ilike
> '%test%'; QUERY PLAN
> -------------------------------------------------------------
>   Seq Scan on neighbors  (cost=0.00..17449.64 rows=774 width=37)
>     Filter: ((filename)::text ~~* '%test%'::text)

I just looked at your query.   What you have above is an "unanchored text 
search", where you are looking for a snippet of text anywhere in the field.   
Such a search *cannot* be indexed using a regular index.

Instead, you need to employ the TSearch full text searching module for 
PostgreSQL.    
hmmm ... the Tsearch home page appears to be down.  Check out the readme in 
your postgreSQL source code:  PG_SOURCE/contrib/tsearch/readme
 
-- 
Josh Berkus
Aglio Database Solutions
San Francisco



view thread (2+ messages)

Message-ID: <200309291009.31470.josh@agliodbs.com>
Permalink:  ../200309291009.31470.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200309291009.31470.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-sql@postgresql.org
  Cc: josh@agliodbs.com, a_kretschmer@gmx.de
  Subject: Re: postgres index on ILIKE
  In-Reply-To: <200309291009.31470.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