From: | "Dann Corbit" <DCorbit(at)connx(dot)com> |
---|---|
To: | "Stefan Sturm" <stefan(dot)s(dot)sturm(at)googlemail(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Optimizing a like-cause |
Date: | 2008-07-22 20:29:37 |
Message-ID: | D425483C2C5C9F49B5B7A41F8944154701000F9A@postal.corporate.connx.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Stefan Sturm
Sent: Tuesday, July 22, 2008 11:31 AM
To: pgsql-general(at)postgresql(dot)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.
<<
From | Date | Subject | |
---|---|---|---|
Next Message | Alan Hodgson | 2008-07-22 20:30:11 | Re: Optimizing a like-cause |
Previous Message | Andrej Ricnik-Bay | 2008-07-22 19:42:50 | Re: Problems Restarting PostgreSQL Daemon |