Re: Can LIKE under utf8 use INDEXes?

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Robert James <srobertjames(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Can LIKE under utf8 use INDEXes?
Date: 2009-07-22 18:49:46
Message-ID: 1248288586.23273.2.camel@monkey-cat.sm.truviso.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeremy Brown 2009-07-22 19:04:40 Select Column Auditing/Logging
Previous Message Greg Stark 2009-07-22 18:37:41 Re: Can LIKE under utf8 use INDEXes?