Re: Weird indices

From: Joseph Shraibman <jks(at)selectacast(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Weird indices
Date: 2001-02-20 03:05:50
Message-ID: 3A91DF0E.712D2FCB@selectacast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
>
> Joseph Shraibman <jks(at)selectacast(dot)net> writes:
> > 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).
>
> The name of the game here is to make a plan *without* actually going
> out and expending large amounts of time to find out the true state of
> affairs; by the time you know for sure, you've already done the query.

Well I'd hope that extracting the count from the index should be very
low cost. That is what indecies are for.

> We have to do a certain amount of guessing, otherwise the planner will
> be a net drag on performance. Accordingly, the estimates will never be
> perfectly accurate.

But certain things could be done. Like planning for the case of there
being a single not null value, and updating the indecies not to point at
expired rows. Isn't the point of a vacuum to get rid of old rows? Then
why doesn't it update the index as well?

I mean the explain shows that getting the count(*) from the field that
is indexed has to do a seq scan, presumably to determine if the rows are
in fact valid. That is ridiculous.

--
Joseph Shraibman
jks(at)selectacast(dot)net
Increase signal to noise ratio. http://www.targabot.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joseph Shraibman 2001-02-20 03:08:54 Re: Weird indices
Previous Message Tom Lane 2001-02-20 02:55:28 Re: index used when casting to different type?