pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: simon godden <sgodden@gmail.com>
Cc: Heikki Linnakangas <heikki@enterprisedb.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: simple case using index on windows but not on linux
Date: Wed, 04 Oct 2006 11:39:16 +0100
Message-ID: <45238F54.70609@archonet.com> (raw)
In-Reply-To: <168519350610040240k346bd99fj9537822d79443f8c@mail.gmail.com>
References: <168519350610040048m7c4031e3t1a24b3fd4d9265a3@mail.gmail.com>
	<45237AD0.50604@enterprisedb.com>
	<168519350610040219n648a282hf159ff272e0f672a@mail.gmail.com>
	<45238085.3000407@archonet.com>
	<168519350610040240k346bd99fj9537822d79443f8c@mail.gmail.com>

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



view thread (12+ messages)  latest in thread

Message-ID: <45238F54.70609@archonet.com>
Permalink:  ../45238F54.70609@archonet.com/
Also on:    postgresql.org/message-id/45238F54.70609@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: dev@archonet.com, sgodden@gmail.com, heikki@enterprisedb.com
  Subject: Re: simple case using index on windows but not on linux
  In-Reply-To: <45238F54.70609@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox