Re: postgres index on ILIKE

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Alex Kretschmer <a_kretschmer(at)gmx(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: postgres index on ILIKE
Date: 2003-09-29 17:09:31
Message-ID: 200309291009.31470.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Browse pgsql-sql by date

  From Date Subject
Next Message GRIMOIS Eric 2003-09-29 17:12:08 Re: SRF Functions don't want to return empty tuple
Previous Message Josh Berkus 2003-09-29 17:02:14 Re: postgres index on ILIKE