Re: query plan with index having a btrim is different for strings of different length - Mailing list pgsql-performance

From Richard Yen
Subject Re: query plan with index having a btrim is different for strings of different length
Date
Msg-id 3EF5395F-0F95-4313-B64A-ECAAE2880C57@richyen.com
Whole thread Raw
In response to Re: query plan with index having a btrim is different for strings of different length  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-performance
On Dec 10, 2008, at 4:08 PM, Tom Lane wrote:

> Richard Yen <dba@richyen.com> writes:
>> Is there any way to tune this so that for the common last names,
>> the query
>> run time doesn't jump from <1s to >300s?
>
> Well, as near as I can tell there's factor of a couple hundred
> difference between the frequencies of 'smith' and 'smithers', so
> you shouldn't really expect similar runtimes for the two cases.
>
> Having said that, I still think you should try to index both first
> and last name.  Also I wonder whether the index on owner is worth
> having at all.  It definitely doesn't seem worthwhile to index the
> entries with owner = -1, since there are so many; so maybe you could
> make it a partial index that excludes those entries, in order to
> prevent
> the planner from trying to use it for this case.

Created the 2-col index, and the query runs much faster on all
permutations.

Thanks much for all your help,
--Richard

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: query plan with index having a btrim is different for strings of different length
Next
From: Matthew Wakeling
Date:
Subject: Re: Experience with HP Smart Array P400 and SATA drives?