pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andy <frum@ar-sd.net>
To: pgsql-performance@postgresql.org
Subject: LIKE search and performance
Date: Wed, 23 May 2007 18:08:49 +0300
Message-ID: <009501c79d4c$445428f0$0b00a8c0@mpsro.dom> (raw)

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.

view thread (29+ messages)  latest in thread

Message-ID: <009501c79d4c$445428f0$0b00a8c0@mpsro.dom>
Permalink:  ../009501c79d4c$445428f0$0b00a8c0@mpsro.dom/
Also on:    postgresql.org/message-id/009501c79d4c$445428f0$0b00a8c0@mpsro.dom

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: frum@ar-sd.net
  Subject: Re: LIKE search and performance
  In-Reply-To: <009501c79d4c$445428f0$0b00a8c0@mpsro.dom>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox