Thanks. You have saved my life!
I should perhaps have noticed the bit in the administrator's guide on
localisation.
Never thought it would be relevant.
I have reloaded the database after a new initdb and restarting
postmaster after changing the environment ("export LANG=C").
Everything now works.
(I write in all this detail so that the next poor sod doesn't have to go
through the same hellish experience :->
Llew
> Probably you initialized the database in non-C locale.
> Anchored searches can only be optimized with index scans in C
> locale; the index ordering isn't necessarily right in other locales.
>
> You can check the database locale with
> contrib/pg_controldata, or if that's not handy try
> od -c $PGDATA/global/pg_control
> and look for locale names near the end of the file.
>
> regards, tom lane
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an
> appropriate subscribe-nomail command to
> majordomo@postgresql.org so that your message can get through
> to the mailing list cleanly
>