Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 0E4089FA65C for ; Wed, 23 May 2007 12:28: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 15910-03 for ; Wed, 23 May 2007 12:28:30 -0300 (ADT) X-Greylist: delayed 00:22:16.461646 by SQLgrey-1.7.5 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 6D3969FA4D4 for ; Wed, 23 May 2007 12:28:30 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from ar-sd.net (unknown [212.146.96.162]) by svr4.postgresql.org (Postfix) with ESMTP id 3639C5AF027 for ; Wed, 23 May 2007 15:06:12 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by ar-sd.net (Postfix) with ESMTP id C99A4FBEB0 for ; Wed, 23 May 2007 18:06:05 +0300 (EEST) Received: from ar-sd.net ([127.0.0.1]) by localhost (ar-sd.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 30474-01 for ; Wed, 23 May 2007 18:05:45 +0300 (EEST) Received: from andypc (andypc.mpsro.dom [192.168.0.11]) by ar-sd.net (Postfix) with ESMTP id A0491FBE9B for ; Wed, 23 May 2007 18:05:45 +0300 (EEST) From: "Andy" To: Subject: LIKE search and performance Date: Wed, 23 May 2007 18:08:49 +0300 Message-ID: <009501c79d4c$445428f0$0b00a8c0@mpsro.dom> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0096_01C79D65.69A160F0" X-Mailer: Microsoft Office Outlook 11 thread-index: AcedTEI32cXEQuFWSsScI7e96csWlA== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-Virus-Scanned: by amavisd-new at ar-sd.net X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/451 X-Sequence-Number: 24841 This is a multi-part message in MIME format. ------=_NextPart_000_0096_01C79D65.69A160F0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit 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? I tried to make indexes on the columns but no success. PG 8.2 Regards, Andy. ------=_NextPart_000_0096_01C79D65.69A160F0 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable
Hi,=20
 
I have = a table with=20 varchar and text columns, and I have to search through these text in the = whole=20 table.
 
An = example would=20 be:
SELECT = *=20 FROM=20 table
          &nbs= p;            = ;     =20 WHERE name like '%john%' or street like '%srt%'
 
Anyway, the query=20 planner always does seq scan on the whole table and that takes some = time. How=20 can this be optimized or made in another way to be = faster?
 
I = tried to make=20 indexes on the columns but no success.
 
PG=20 8.2
 
Regards,
Andy.
------=_NextPart_000_0096_01C79D65.69A160F0--