Andreas Joseph Krogh <[EMAIL PROTECTED]> writes:
> I forgot to mention: I use UTF-8. IIRC, it works fine with C-locale without
> the "varchar_pattern_ops", which is why it works for you I think.
That shouldn't make any difference, and doesn't for me in testing here:
regression=# select version();
version
-----------------------------------------------------------------------------------------------------------
PostgreSQL 8.2.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2
20070626 (Red Hat 4.1.2-13)
(1 row)
regression=# show lc_collate;
lc_collate
------------
en_US.utf8
(1 row)
regression=# show server_encoding ;
server_encoding
-----------------
UTF8
(1 row)
regression=# \d person
Table "public.person"
Column | Type | Modifiers
-----------+-------------------+-----------------------------------------------------
id | integer | not null default
nextval('person_id_seq'::regclass)
firstname | character varying |
lastname | character varying |
Indexes:
"person_pkey" PRIMARY KEY, btree (id)
"person_lowerfullname_idx" btree ((lower(COALESCE(firstname, ''::character
varying)::text) || lower(COALESCE(lastname, ''::character varying)::text)))
regression=# explain select id from person order by (lower(COALESCE(firstname,
'')) || lower(COALESCE(lastname, ''))) ASC limit 1;
QUERY PLAN
-------------------------------------------------------------------------------------------------
Limit (cost=0.00..0.08 rows=1 width=68)
-> Index Scan using person_lowerfullname_idx on person (cost=0.00..62.25
rows=800 width=68)
(2 rows)
So there's something going on that you haven't told us about your installation.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq