pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris <dmagick@gmail.com>
To: genekhart@gmail.com
Cc: pgsql-performance@postgresql.org
Subject: Re: optimizing LIKE '%2345' queries
Date: Wed, 05 Jul 2006 10:22:42 +1000
Message-ID: <44AB0652.2080606@gmail.com> (raw)
In-Reply-To: <430d92a20607041327r4bcd6306ofec4adec6856c037@mail.gmail.com>
References: <430d92a20607021450i1d228350j292d68e987ed58de@mail.gmail.com>
	<Pine.LNX.4.64.0607041408450.20387@oynpxoyhr.vnfv.npgvirzrqvngrpu.pbz>
	<430d92a20607041327r4bcd6306ofec4adec6856c037@mail.gmail.com>

Gene wrote:
> Thanks for the suggestion. Actually I went ahead and created a reverse
> function using plpgsql, created an index using reverse column and now
> my queries use "where reverse(column) like reverse('%2345') and it's
> using the index like i hoped it would! Now if I could figure out how
> to optimize like  '%2345%' queries. I don't want to create many
> indexes though the table is very write heavy.

You can't because that text can be anywhere inside the database field, 
so the whole field basically has to be checked to see if it's there.

You could check out full text indexing (tsearch2).

<shameless plug>
http://www.designmagick.com/article/27/PostgreSQL/Introduction-to-Full-Text-Indexing

-- 
Postgresql & php tutorials
http://www.designmagick.com/



view thread (5+ messages)

Message-ID: <44AB0652.2080606@gmail.com>
Permalink:  ../44AB0652.2080606@gmail.com/
Also on:    postgresql.org/message-id/44AB0652.2080606@gmail.com

 · 

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: dmagick@gmail.com, genekhart@gmail.com
  Subject: Re: optimizing LIKE '%2345' queries
  In-Reply-To: <44AB0652.2080606@gmail.com>

* 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