From: Alvaro Herrera <alvherre@commandprompt.com>
To: Florian Weimer <fw@deneb.enyo.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: Index to support LIKE '%suffix' queries
Date: Sat, 25 Feb 2006 15:13:46 -0300
Message-ID: <20060225181346.GA6092@surnet.cl> (raw)
In-Reply-To: <877j7jfhqs.fsf@mid.deneb.enyo.de>
References: <87mzgfh69m.fsf@mid.deneb.enyo.de>
<11673.1140888147@sss.pgh.pa.us>
<877j7jfhqs.fsf@mid.deneb.enyo.de>
> > Florian Weimer <fw@deneb.enyo.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. You need to also reverse the patter at query-time as well.
This will make the % be at the end of the pattern, making it an
indexable condition.
Whether or not this beats tsearch2 is something you should investigate ...
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
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-sql@postgresql.org
Cc: alvherre@commandprompt.com, fw@deneb.enyo.de, tgl@sss.pgh.pa.us
Subject: Re: Index to support LIKE '%suffix' queries
In-Reply-To: <20060225181346.GA6092@surnet.cl>
* 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