pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andreas Joseph Krogh <andreak@officenet.no>
Cc: pgsql-sql@postgresql.org, "Rodrigo De León" <rdeleonp@gmail.com>
Subject: Re: PG won't use index on ORDER BY <expression>
Date: Thu, 09 Aug 2007 21:35:13 -0400
Message-ID: <7474.1186709713@sss.pgh.pa.us> (raw)
In-Reply-To: <200708092310.53309.andreak@officenet.no>
References: <200708092018.44111.andreak@officenet.no>
	<200708092238.46284.andreak@officenet.no>
	<a55915760708091357m4632c952s10bdafd235765941@mail.gmail.com>
	<200708092310.53309.andreak@officenet.no>

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.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



view thread (9+ messages)  latest in thread

Message-ID: <7474.1186709713@sss.pgh.pa.us>
Permalink:  ../7474.1186709713@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7474.1186709713@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andreak@officenet.no, rdeleonp@gmail.com
  Subject: Re: PG won't use index on ORDER BY <expression>
  In-Reply-To: <7474.1186709713@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox