On Mon, 19 Feb 2001, Joseph Shraibman wrote:
> Joseph Shraibman wrote:
> >
>
> > Can't postgres do the index lookup first and find out there are only a
> > few tuples that might match?
> >
>
> o=# select count(*) from usertable where p in(1,33) group by p;
> count
> -------
> 16
> 502
> (2 rows)
>
> This raises some other questions. Why can't postgres get the count(*)
> from the index? Why doesn't it predict the correct number of rows in
> the planner? (25 estimated vs 16 actual).
First question: Mostly the same reason. Not all of the index entries
are necessarily real active rows that you can see, so you would still
have to hit the heap file to get that data, so I'd guess you're already
hitting the entire heap file.
[Tom answered the second]