Re: query optimizer questions - Mailing list pgsql-general

From Allan Engelhardt
Subject Re: query optimizer questions
Date
Msg-id 3B436B7E.E8FC49CF@cybaea.com
Whole thread Raw
In response to query optimizer questions  (Robert Berger <rwb@vtiscan.com>)
Responses Re: Re: query optimizer questions  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-general
> Thanks. How do I set the locale?

Short answer:

  bash$ LANG=C initdb

Longer answer:

I find locale support in PostgreSQL confusing.  The locale of the current user at the time of initialising the database
determinesthe collating order (e.g. is 'a' < 'A').  This in turns affect things like indexing (as described below).
Thelocale of the account that is running the current  postmaster  defines format conversions (e.g. the currency symbol
into_char(1,'L99')).  The locale of the current process requesting a query defines how the user expects to see the
result,and is (of course) ignored by PostgreSQL. 

To make matters worse: On Red Hat 7.1 (US boxed set) the default locale is set in /etc/sysconf/i18n to en_US, i.e.
AmericanEnglish.  Fine, except some Americans may be surprised to learn that 'A' > 'a'.  When you start the postgresql
servicewithout doing an initdb first, the script will helpfully copy i18n to  ~postgres/initdb.i18n so you have a
recordof the locale (and can re-set it).  Except it never uses this file.  In fact, the postmaster service runs in the
defaultlocale  *for root*.  A previous version of RH did go through the trouble of sourcing initdb.i18n in
.bash_profile,but it does nothing for postmaster which is started as su -l postgres -s /bin/sh ... 

In order to start postmaster on RH7.1 with a locale that is different from the default (actually: different from root)
youshould create ~postgres/.profile with the content 

PGLIB=/usr/lib/pgsql
PGDATA=/var/lib/pgsql/data
export PGLIB PGDATA
[ -f $PGDATA/../initdb.i18n ] &&  source $PGDATA/../initdb.i18n

You may, of course, have to change the path. You may want to add that last line to your ~postgres/.bash_profile as
well,in order to avoid future confusion.... 

If you dont have initdb.i18n, just delete the content of the data directory and start the postgres service.  The result
shouldlook something like 

LANG="en_US"
export LANG LC_ALL LC_CTYPE LC_COLLATE LC_NUMERIC LC_CTYPE LC_TIME

for a default installation, but of course you want LANG="C"


Hope this makes sense to somebody....e-mail if I've managed to confuse anybody, including myself :-)


Allan.


pgsql-general by date:

Previous
From: "Vilson farias"
Date:
Subject: sequencial scans
Next
From: Stephan Szabo
Date:
Subject: RE: Re: 7.1.2 ERROR: UNIQUE constraint matching given keys for referenced table ......