Re: Can LIKE under utf8 use INDEXes? - Mailing list pgsql-general

From Jeff Davis
Subject Re: Can LIKE under utf8 use INDEXes?
Date
Msg-id 1248288586.23273.2.camel@monkey-cat.sm.truviso.com
Whole thread Raw
In response to Can LIKE under utf8 use INDEXes?  (Robert James <srobertjames@gmail.com>)
List pgsql-general
On Wed, 2009-07-22 at 12:57 -0400, Robert James wrote:
> The docs suggest a workaround, to allow LIKE to use indexes - but I
> couldn't figure it out.  Although I'm stuck with locale utf8, all my
> data is 7-bit ascii.  I'm doing a tremendous amount of WHERE x LIKE
> 'abc%' - what's the best way to set up a good index?

Create the index using text_pattern_ops, and I think it will do what you
want.

CREATE INDEX foo_t_idx ON foo (t text_pattern_ops);

Regards,
    Jeff Davis


pgsql-general by date:

Previous
From: Greg Stark
Date:
Subject: Re: Can LIKE under utf8 use INDEXes?
Next
From: Andy Colson
Date:
Subject: Re: Best way to import data in postgresl (not "COPY")