Re: postgres index on ILIKE - Mailing list pgsql-sql

From Josh Berkus
Subject Re: postgres index on ILIKE
Date
Msg-id 200309291009.31470.josh@agliodbs.com
Whole thread Raw
List 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


pgsql-sql by date:

Previous
From: "shengqj"
Date:
Subject: help
Next
From: teknokrat
Date:
Subject: does postgresql execute unions in parallel?