Re: Indexs and prolems with. - Mailing list pgsql-general

From Tom Lane
Subject Re: Indexs and prolems with.
Date
Msg-id 8607.1013028627@sss.pgh.pa.us
Whole thread Raw
In response to Indexs and prolems with.  ("Michael McAlpine" <mikem@vis.oregonian.com>)
List pgsql-general
"Michael McAlpine" <mikem@vis.oregonian.com> writes:
> 1)  explain select * from table1 where charcol1 = 'asdfasd'
>      Index Scan using idx_charcol1  on table1  (cost=0.00..5.00 rows=1 width=456)

> 4)   explain select * from table1 where charcol2  = 'asdfasd'
>      Seq Scan on table1  (cost=0.00..234872.84 rows=168205 width=456)

Notice the difference in the estimated number of matching rows ---
that's what's persuading the planner that an indexscan would be a bad idea.
Why is that?  Is charcol2 full of lots of duplicates?

It'd be useful to know what version you are using and what you get from
(assuming 7.1)

select attname,attdispersion,s.*
from pg_statistic s, pg_attribute a, pg_class c
where starelid = c.oid and attrelid = c.oid and staattnum = attnum
and relname = 'table1';

            regards, tom lane

pgsql-general by date:

Previous
From: "Sykora, Dale"
Date:
Subject: Re: Postal code radius searches
Next
From: greg@turnstep.com
Date:
Subject: Re: Commit , Rollback