Re: 7.3 no longer using indexes for LIKE queries

From: Matthew Gabeler-Lee <mgabelerlee(at)zycos(dot)com>
To: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: 7.3 no longer using indexes for LIKE queries
Date: 2002-12-04 15:00:30
Message-ID: ABABFB80F35AD311848B0090279918EF010B9B61@ZYCOSNT2.hq.zycos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Can someone please elaborate on why it stops doing this optimization? The
only reasons for it that I can think of for it to be unsafe in a locale is
that two characters that are not the same character still compare as being
equal (does this ever really happen?). Otherwise, saying "foo LIKE 'xxx%'"
is really saying are the first 3 characters of foo equal to 'xxx'.
Regardless of sort order, in a sorted list of values, anything starting with
'xxx' should appear together, and thus be optimizable by an index unless
there are values of x and y for which 'x' = 'y'. If that were the case,
though, you couldn't use the index for "foo = 'xxx'" either, which is
obviously not the case.

So, can someone enlighten me as to where I'm making a wrong assumption or
something here?

-Matt

-----Original Message-----
From: Joe Conway [mailto:mail(at)joeconway(dot)com]
Sent: Tuesday, December 03, 2002 19:31

Whats the output of pg_controldata, specifically, what is LC_COLLATE? If it
isn't "C", then LIKE won't use your index.

See:
http://developer.postgresql.org/docs/postgres/charset.html

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2002-12-04 15:11:09 Re: Efficient Boolean Storage
Previous Message Tom Lane 2002-12-04 14:34:05 Re: 7.3 pg_ctl anomaly