Re: Weird indices - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Weird indices
Date
Msg-id Pine.BSF.4.21.0102191840260.85555-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: Weird indices  (Joseph Shraibman <jks@selectacast.net>)
List pgsql-general
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]


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: index used when casting to different type?
Next
From: adb
Date:
Subject: Re: index used when casting to different type?