Re: PG won't use index on ORDER BY - Mailing list pgsql-sql

From Tom Lane
Subject Re: PG won't use index on ORDER BY
Date
Msg-id 7474.1186709713@sss.pgh.pa.us
Whole thread Raw
In response to Re: PG won't use index on ORDER BY  (Andreas Joseph Krogh <andreak@officenet.no>)
List pgsql-sql
Andreas Joseph Krogh <andreak@officenet.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.4on 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           |
notnull 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,
''::charactervarying)::text) || lower(COALESCE(lastname, ''::character varying)::text)))
 

regression=# explain select id from person order by (lower(COALESCE(firstname, '')) ||  lower(COALESCE(lastname, '')))
ASClimit 1;                                          QUERY PLAN                                            
 
-------------------------------------------------------------------------------------------------Limit
(cost=0.00..0.08rows=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


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: PG won't use index on ORDER BY
Next
From: Gregory Stark
Date:
Subject: Re: PG won't use index on ORDER BY