pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: pgsql-performance@postgresql.org
Cc: Dave Cramer <pg@fastcrypt.com>
Subject: Re: Why the difference in plans ?
Date: Fri, 7 Mar 2008 17:23:24 -0800
Message-ID: <200803071723.25261.josh@agliodbs.com> (raw)
In-Reply-To: <5AA2522A-E359-4BA2-871C-5C5EA718F31F@fastcrypt.com>
References: <E0CF6B25-5191-4AF7-8C72-E67FA2F1AE5E@fastcrypt.com>
	<200803060926.38708.josh@agliodbs.com>
	<5AA2522A-E359-4BA2-871C-5C5EA718F31F@fastcrypt.com>

Dave,
>      "user_profile_pkey" PRIMARY KEY, btree (uid) CLUSTER
>      "user_profile_name_idx" UNIQUE, btree (name varchar_pattern_ops)
>      "user_profile_name_key" UNIQUE, btree (name)
>      "user_profile_uploadcode_key" UNIQUE, btree (uploadcode)
>      "user_profile_active_idx" btree (isactive)
>      "user_profile_areacode_index" btree (areacode)
>      "user_profile_gender_idx" btree (gender)

You need to change one of the name indexes to a functional index on 
lower(firstname).  That'll speed the query up considerably.

I'm still puzzled as to why the index is being used at all in the 2nd 
query, as it seems very unlikely to work out, but the above is the 
practical solution to your problem.


-- 
--Josh

Josh Berkus
PostgreSQL @ Sun
San Francisco



view thread (13+ messages)

Message-ID: <200803071723.25261.josh@agliodbs.com>
Permalink:  ../200803071723.25261.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200803071723.25261.josh@agliodbs.com

 · 

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-performance@postgresql.org
  Cc: josh@agliodbs.com, pg@fastcrypt.com
  Subject: Re: Why the difference in plans ?
  In-Reply-To: <200803071723.25261.josh@agliodbs.com>

* 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