From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andreas Joseph Krogh <andreak(at)officenet(dot)no> |
Cc: | pgsql-sql(at)postgresql(dot)org, "Rodrigo De =?utf-8?q?Le=C3=B3n?=" <rdeleonp(at)gmail(dot)com> |
Subject: | Re: PG won't use index on ORDER BY <expression> |
Date: | 2007-08-10 01:35:13 |
Message-ID: | 7474.1186709713@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Andreas Joseph Krogh <andreak(at)officenet(dot)no> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Gregory Stark | 2007-08-10 03:10:47 | Re: PG won't use index on ORDER BY <expression> |
Previous Message | Tom Lane | 2007-08-09 23:35:08 | Re: PG won't use index on ORDER BY <expression> |