Re: "between" is using index but "like" is not

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jesper Krogh <jesper(at)krogh(dot)cc>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: "between" is using index but "like" is not
Date: 2004-08-25 18:59:59
Message-ID: 2065.1093460399@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Jesper Krogh <jesper(at)krogh(dot)cc> writes:
> Why doesn't it use an index on the "like" operator when it doesn't
> contain a wildcard in the beginning of the pattern?

Probably because your locale isn't C --- locale-specific sort ordering
usually isn't compatible with the needs of LIKE, so we can only make
that optimization in C locale.

You can either re-initdb in C locale, or (if you're using 7.4) create a
specialized index with non-locale-dependent comparison operators. See
the manual concerning specialized index operator classes.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Gaetano Mendola 2004-08-26 01:51:01 Re: "between" is using index but "like" is not
Previous Message Josh Berkus 2004-08-25 17:38:37 Re: "between" is using index but "like" is not