Re: Trouble with index in 7.1 - Mailing list pgsql-novice

From Tom Lane
Subject Re: Trouble with index in 7.1
Date
Msg-id 601.1021523570@sss.pgh.pa.us
Whole thread Raw
In response to Trouble with index in 7.1  (gerry.smit@lombard.ca)
List pgsql-novice
gerry.smit@lombard.ca writes:
> Hi folks. We're having a baffling time with Postgres 7.1

Updating to 7.2 might help.

> cen_db=> explain select * from pol_xref_d where policy_no=1200079;

> Seq Scan on pol_xref_d  (cost=0.00..22299.22 rows=8325 width=80)

> Sequential Scan  !!!!  Good God, why ?

Because it thinks a substantial fraction of your table will be visited
(note the rows=8325 estimate).  My guess is that you have some one value
of policy_no that is extremely common, and that that is fooling the
7.1 planner into thinking the table contains only a few distinct values
of policy_no --- which would make a seqscan an appropriate choice.

7.2 keeps more extensive stats and is more able to deal with scenarios
where there are a few common values and lots of not-so-common values.

            regards, tom lane

pgsql-novice by date:

Previous
From: Chris
Date:
Subject: Re: Answering my own question
Next
From: john-paul delaney
Date:
Subject: Re: data-type for image files