pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@commandprompt.com>
To: Thomas Samson <koollman@gmail.com>
Cc: Ulrich Habel <espero7757@gmx.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: query planner: automatic rescribe of LIKE to BETWEEN ?
Date: Tue, 22 Aug 2006 14:49:57 -0400
Message-ID: <20060822184957.GE25475@alvh.no-ip.org> (raw)
In-Reply-To: <4e96c6600608221121p2afc603bx90fcf879aab47d96@mail.gmail.com>
References: <200608221922.59734.espero7757@gmx.net>
	<20060822174539.GD25475@alvh.no-ip.org>
	<4e96c6600608221121p2afc603bx90fcf879aab47d96@mail.gmail.com>

Thomas Samson wrote:
> On 8/22/06, Alvaro Herrera <alvherre@commandprompt.com> wrote:
> >Ulrich Habel wrote:
> >> Hello all,
> >> had an idea of optimizing a query that may work generally.
> >>
> >> In case a 'column' is indexed, following two alterations could be done
> >> I think:
> >>
> >> A)
> >>
> >>   select ... where column ~ '^Foo'     -->  Seq Scan
> >
> >This is not true.  You can make this query use an index if you create it
> >with opclass varchar_pattern_ops or text_pattern_ops, as appropiate.
> >
> >Thus you don't need any hack here.
> >
> 
> And in the case of more general expression, like:
> select ... where column ~ 'something';
> 
> Is there a way to optimise this ? (in the case where 'something' is not
> a word, but a part of a word)

Not sure.  I'd try tsearch2 or pg_trgm (or pg_tgrm, whatever it's
called).  It's trigram indexing.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support



view thread (5+ messages)  latest in thread

Message-ID: <20060822184957.GE25475@alvh.no-ip.org>
Permalink:  ../20060822184957.GE25475@alvh.no-ip.org/
Also on:    postgresql.org/message-id/20060822184957.GE25475@alvh.no-ip.org

 · 

reply

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: alvherre@commandprompt.com, koollman@gmail.com, espero7757@gmx.net
  Subject: Re: query planner: automatic rescribe of LIKE to BETWEEN ?
  In-Reply-To: <20060822184957.GE25475@alvh.no-ip.org>
  References: <200608221922.59734.espero7757@gmx.net> <20060822174539.GD25475@alvh.no-ip.org> <4e96c6600608221121p2afc603bx90fcf879aab47d96@mail.gmail.com> <20060822184957.GE25475@alvh.no-ip.org>

* 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