Re: Index to support LIKE '%suffix' queries

From: Florian Weimer <fw(at)deneb(dot)enyo(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Index to support LIKE '%suffix' queries
Date: 2006-03-01 07:19:40
Message-ID: 874q2ik4xf.fsf@mid.deneb.enyo.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

* Alvaro Herrera:

>> > Florian Weimer <fw(at)deneb(dot)enyo(dot)de> writes:
>> >> Is it possible to create an index to support queries of the form
>> >> "column LIKE '%suffix'" (similar to an ordinary index for LIKE
>> >> 'prefix%', which I also need)?
>
> It is possible to create a functional index on the reverse of the
> string.

Okay. Is there a predefined reverse function? I couldn't find one
and I'm wondering if I just missed it.

> Whether or not this beats tsearch2 is something you should investigate ...

It's also possible that for this type of query, sequential scans are
good enough. I forgot that they are quite fast.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mauricio Fernandez A. 2006-03-01 10:17:15 Re: Slow update SQL
Previous Message Michael Fuhr 2006-03-01 05:19:57 Re: regarding grant option