Re: Why won't it index scan? - Mailing list pgsql-general

From Ed L.
Subject Re: Why won't it index scan?
Date
Msg-id 200605171407.24332.pgsql@bluepolka.net
Whole thread Raw
In response to Re: Why won't it index scan?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Why won't it index scan?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Wednesday May 17 2006 1:26 pm, Tom Lane wrote:
> "Ed L." <pgsql@bluepolka.net> writes:
> > I'm trying to understand what happened here, and I have a
> > theory.
>
> The problem is the horrid misestimation of the selectivity of
> "nursestation_key = 40":
>
>                ->  Bitmap Index Scan on
> idx_visit_nursestation_key  (cost=0.00..69.35 rows=4956
> width=0) (actual time=0.158..0.158 rows=6 loops=1) Index Cond:
> (nursestation_key = 40)
>
> When you're off by a factor of 800+ on the number of matching
> rows, you're going to arrive at a less than optimal plan.
> Increasing the stats target on visit.nursestation_key would be
> the solution.

Ok, makes sense.

So, does this sound like we just happened to get repeatedly
horribly unrepresentative random samples with stats target at
10?  Are we at the mercy of randomness here?  Or is there a
better preventive procedure we can follow to systematically
identify this kind of situation?

Ed

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: autovacuum "connections" are hidden
Next
From: Don Y
Date:
Subject: ALTER SEQUENCE