Re: optimizing LIKE '%2345' queries - Mailing list pgsql-performance

From Gene
Subject Re: optimizing LIKE '%2345' queries
Date
Msg-id 430d92a20607041327r4bcd6306ofec4adec6856c037@mail.gmail.com
Whole thread Raw
In response to Re: optimizing LIKE '%2345' queries  (Tarhon-Onu Victor <mituc@iasi.rdsnet.ro>)
Responses Re: optimizing LIKE '%2345' queries  (Chris <dmagick@gmail.com>)
List pgsql-performance
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.

> > Is the only way to create a reverse function and create an index using
> > the reverse function and modify queries to use:
> >
> > where reverse(column) like reverse('%2345') ?
>
>         Hmm.. interesting.
>         If (and only if) the records stored in "column" column have fixed
> length (say, all are 50 characters in length) you could create and index
> on, say, substring(column,45,50), and use this in the WHERE clauses in
> your queries.
>         Or if the length of those records is not the same maybe it is
> feasible to create an ondex on substring(column, length(column)-5,
> length(column)).
>
> --
> Any views or opinions presented within this e-mail are solely those of
> the author and do not necessarily represent those of any company, unless
> otherwise expressly stated.
>

pgsql-performance by date:

Previous
From: Nolan Cafferky
Date:
Subject: Re: how to tune this query.
Next
From: Chris
Date:
Subject: Re: optimizing LIKE '%2345' queries