Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id EEB2D9FB5C7 for ; Wed, 23 May 2007 13:18:35 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 04312-09 for ; Wed, 23 May 2007 13:18:30 -0300 (ADT) X-Greylist: delayed 00:26:05.8095 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 93CB19FB602 for ; Wed, 23 May 2007 13:18:30 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from mail.finestmedia.ee (mail.finestmedia.ee [213.180.31.2]) by svr4.postgresql.org (Postfix) with ESMTP id 057565AF02A for ; Wed, 23 May 2007 15:52:23 +0000 (GMT) Received: from [192.168.2.19] (err.fm.sise [192.168.2.19]) by mail.finestmedia.ee (Postfix) with ESMTP id 434E4492178 for ; Wed, 23 May 2007 18:52:21 +0300 (EEST) Message-ID: <46546335.5000109@finestmedia.ee> Date: Wed, 23 May 2007 18:52:21 +0300 From: Rigmor Ukuhe User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 Cc: pgsql-performance@postgresql.org Subject: Re: LIKE search and performance References: <009501c79d4c$445428f0$0b00a8c0@mpsro.dom> In-Reply-To: <009501c79d4c$445428f0$0b00a8c0@mpsro.dom> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200705/458 X-Sequence-Number: 24848 Andy wrote: > Hi, > > I have a table with varchar and text columns, and I have to search > through these text in the whole table. > > An example would be: > SELECT * FROM table > WHERE name like '%john%' or street like '%srt%' > > Anyway, the query planner always does seq scan on the whole table and > that takes some time. How can this be optimized or made in another way > to be faster? Use tsearch2 (http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/) for full text indexing. Rigmor > > I tried to make indexes on the columns but no success. > > PG 8.2 > > Regards, > Andy.