Re: Why the difference in plans ? - Mailing list pgsql-performance

From Josh Berkus
Subject Re: Why the difference in plans ?
Date
Msg-id 200803071723.25261.josh@agliodbs.com
Whole thread Raw
In response to Re: Why the difference in plans ?  (Dave Cramer <pg@fastcrypt.com>)
List pgsql-performance
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

pgsql-performance by date:

Previous
From: Mark Kirkwood
Date:
Subject: Re: count * performance issue
Next
From: Josh Berkus
Date:
Subject: Re: count * performance issue