From: Gene <genekhart@gmail.com>
To: Tarhon-Onu Victor <mituc@iasi.rdsnet.ro>
Cc: pgsql-performance@postgresql.org
Subject: Re: optimizing LIKE '%2345' queries
Date: Tue, 4 Jul 2006 16:27:44 -0400
Message-ID: <430d92a20607041327r4bcd6306ofec4adec6856c037@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0607041408450.20387@oynpxoyhr.vnfv.npgvirzrqvngrpu.pbz>
References: <430d92a20607021450i1d228350j292d68e987ed58de@mail.gmail.com>
<Pine.LNX.4.64.0607041408450.20387@oynpxoyhr.vnfv.npgvirzrqvngrpu.pbz>
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.
>
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: genekhart@gmail.com, mituc@iasi.rdsnet.ro
Subject: Re: optimizing LIKE '%2345' queries
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>
* 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