Re: optimizing LIKE '%2345' queries

From: Tarhon-Onu Victor <mituc(at)iasi(dot)rdsnet(dot)ro>
To: pgsql-performance(at)postgresql(dot)org
Cc: Gene <genekhart(at)gmail(dot)com>
Subject: Re: optimizing LIKE '%2345' queries
Date: 2006-07-04 11:14:23
Message-ID: Pine.LNX.4.64.0607041408450.20387@oynpxoyhr.vnfv.npgvirzrqvngrpu.pbz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Sun, 2 Jul 2006, Gene wrote:

> can use an index and perform as fast as searching with like '2345%'?
>
> 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.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message David Gagnon 2006-07-04 11:55:58 Re: Is postgresql ca do the job for software deployed in ASP
Previous Message Tomasz Ostrowski 2006-07-04 08:37:33 Re: query very slow when enable_seqscan=on