From: Ron Mayer <rm_pg@cheapcomplexdevices.com>
To: Alex Turner <armtuk@gmail.com>
Subject: Re: Planner issue
Date: Tue, 22 Mar 2005 15:09:35 -0800
Message-ID: <4240A5AF.4010901@cheapcomplexdevices.com> (raw)
In-Reply-To: <33c6269f05032211366ce4563b@mail.gmail.com>
References: <33c6269f05032206565ca4f9f1@mail.gmail.com>
<42404663.2010504@commandprompt.com>
<33c6269f05032211366ce4563b@mail.gmail.com>
I'm guessing your data is actually more "clustered" than the
"correlation" statistic thinks it is.
Alex Turner wrote:
> trendmls=# explain analyze select listnum from propmain where
> listprice<=300000 and listprice>=200000;
Is that a database of properties like land/houses?
If your table is clustered geographically (by zip code, etc),
the index scan might do quite well because all houses in a
neighborhood may have similar prices (and therefore live on
just a few disk pages). However since high-priced neighborhoods
are scattered across the country, the optimizer would see
a very low "correlation" and not notice this clustering.
If this is the cause, one thing you could do is
CLUSTER your table on propmain_listprice_i. I'm quite
confident it'll fix this particular query - but might
slow down other queries.
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: rm_pg@cheapcomplexdevices.com, armtuk@gmail.com
Subject: Re: Planner issue
In-Reply-To: <4240A5AF.4010901@cheapcomplexdevices.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