Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 61DD29FB3F5 for ; Wed, 4 Oct 2006 07:36:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 79614-02 for ; Wed, 4 Oct 2006 07:36:52 -0300 (ADT) X-Greylist: delayed 01:03:03.962471 by SQLgrey- Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id DE7FC9FB3F4 for ; Wed, 4 Oct 2006 07:36:51 -0300 (ADT) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id B704D740EF; Wed, 4 Oct 2006 11:36:50 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 6374E15EA3; Wed, 4 Oct 2006 11:36:50 +0100 (BST) Message-ID: <45238F54.70609@archonet.com> Date: Wed, 04 Oct 2006 11:39:16 +0100 From: Richard Huxton User-Agent: Thunderbird 1.5.0.7 (X11/20060909) MIME-Version: 1.0 To: simon godden Cc: Heikki Linnakangas , pgsql-performance@postgresql.org Subject: Re: simple case using index on windows but not on linux References: <168519350610040048m7c4031e3t1a24b3fd4d9265a3@mail.gmail.com> <45237AD0.50604@enterprisedb.com> <168519350610040219n648a282hf159ff272e0f672a@mail.gmail.com> <45238085.3000407@archonet.com> <168519350610040240k346bd99fj9537822d79443f8c@mail.gmail.com> In-Reply-To: <168519350610040240k346bd99fj9537822d79443f8c@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.491 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200610/78 X-Sequence-Number: 21207 simon godden wrote: >> If the index isn't used, then we have problem #3. I think this is what >> you are actually seeing. Your locale is something other than "C" and PG >> doesn't know how to use like with indexes. Read up on operator classes >> or change your locale. >> http://www.postgresql.org/docs/8.1/static/indexes-opclass.html > > Aha - that sounds like it - this is the output from locale > > LANG=en_US.UTF-8 > LC_CTYPE="en_US.UTF-8" .. > I guess it cannot determine the collating sequence? It can, but isn't sure that it can rely on LIKE 'A%' being the same as >= 'A' and < 'B' (not always true). Re-creating the index with the right opclass will tell it this is the case. > I'm not too familiar with unix locale issues - does this output match > your problem description? OK - quick intro to locales. Create a file /tmp/sortthis containing the following: ---begin file--- BBB CCC AAA A CAT A DOG ACAT ---end file--- Now run "sort /tmp/sortthis". You'll probably see spaces get ignored. Now run "LANG=C sort /tmp/sortthis". You'll probably see a traditional ASCII ("C") sort. If not try LC_COLLATE rather than LANG. > Can you explain how to change my locale to 'C'? (I'm quite happy for > you to tell me to RTFM, as I know this is not a linux user mailing > list :) You'll want to dump your databases and re-run initdb with a locale of "C" (or no locale). See: http://www.postgresql.org/docs/8.1/static/app-initdb.html That will mean all sorting will be on ASCII value. The problem is that the database picks up the operating-system's default locale when you install it from package. Not always what you want, but then until you understand the implications you can't really decide one way or the other. HTH -- Richard Huxton Archonet Ltd