Re: Strange count(*) implementation? - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Strange count(*) implementation?
Date
Msg-id 20041026122844.GA4378@dcc.uchile.cl
Whole thread Raw
In response to Re: Strange count(*) implementation?  (Henk Ernst Blok <h.e.blok@utwente.nl>)
Responses Re: Strange count(*) implementation?
List pgsql-general
On Tue, Oct 26, 2004 at 01:56:41PM +0200, Henk Ernst Blok wrote:

Hi,

> I assume(d) the more expensive statistics (e.g., value distribution
> info) are updated only when outdated too much or on request (manual
> vacuum). Usually, other/cheap statistics can easily be maintained
> incrementally and thus reflect actual table state after each update. Of
> course, the MVCC principle seems to make things a bit more complicated I
> understand now.

It's not only MVCC; it's also the fact that aggregates are extensible.
So to the system they are just opaque functions and it doesn't know how
to optimize them.

Of course this can be done, e.g. by supplying an optimizing function with
each aggregate that would try to convert the step-by-step aggregate
execution plan into a completely different operation (say by looking at
an index to obtain a max() value), but as you see this is not a trivial
task, and more importantly, it hasn't been done.  Which is to mean, if
you want to try and submit a patch, it could be improved in the future.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"There is evil in the world. There are dark, awful things. Occasionally, we get
a glimpse of them. But there are dark corners; horrors almost impossible to
imagine... even in our worst nightmares." (Van Helsing, Dracula A.D. 1972)


pgsql-general by date:

Previous
From: Neil Conway
Date:
Subject: Re: Strange count(*) implementation?
Next
From: Tino Wildenhain
Date:
Subject: Re: Strange count(*) implementation?