Re: Optimizing a like-cause - Mailing list pgsql-general

From Dann Corbit
Subject Re: Optimizing a like-cause
Date
Msg-id D425483C2C5C9F49B5B7A41F8944154701000F9A@postal.corporate.connx.com
Whole thread Raw
In response to Optimizing a like-cause  (Stefan Sturm <stefan.s.sturm@googlemail.com>)
Responses Re: Optimizing a like-cause
List pgsql-general
-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Stefan Sturm
Sent: Tuesday, July 22, 2008 11:31 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Optimizing a like-cause

Hello,

I'm developing a autocomplete Feature using php and PostgreSQL 8.3.
To fill the autocomplete box I use the following SQL Statement:
select * from _table_ where upper( _field_ ) like '%STRING%';

This SQL Statement takes 900 ms on a Table with 300.000 entries.

What can I do to speed up the Statement? What Index can I set?
>>
If you are searching for words, you could use tsearch2.
If you are searching for arbitrary fragments, an idea like this might
prove helpful:
http://kaiv.wordpress.com/2007/12/11/postgresql-substring-search/

What you are asking for is very difficult, because an ordinary index
won't help (you have a wildcard on the front) and an index on the
reversed word won't help either (you have a wildcard on the back).  So
the standard sort of techniques used to solve it are not perfectly on
target.
<<

pgsql-general by date:

Previous
From: "Bill Wordsworth"
Date:
Subject: pg_query transaction: auto rollback? begin or start?? commit or end???
Next
From: Alan Hodgson
Date:
Subject: Re: Optimizing a like-cause