From: | Neil Conway <neilc(at)samurai(dot)com> |
---|---|
To: | Henk Ernst Blok <h(dot)e(dot)blok(at)utwente(dot)nl> |
Cc: | Tino Wildenhain <tino(at)wildenhain(dot)de>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Strange count(*) implementation? |
Date: | 2004-10-26 12:18:54 |
Message-ID: | 417E40AE.1080001@samurai.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Henk Ernst Blok wrote:
> I assume(d) the more expensive statistics (e.g., value distribution
> info) are updated only when outdated too much or on request (manual
> vacuum).
They are only updated on request -- i.e. when an ANALYZE is issued.
> So if explain can get the most recent count, why
> not use it in the count as well if you know the statistics are still
> acurate?
Aside from the issue of stale statistics, there is another problem:
optimizer statistics are designed to be approximations. They are not
necessarily precise, even if ANALYZE has just been run (for example,
pg_class.reltuples is stored as a floating point number).
A practical problem is that aggregates like count() are implemented via
a general-purpose API; there is currently no provision for bypassing the
API in certain special case scenarios. See here for more info:
http://developer.postgresql.org/docs/postgres/functions-aggregate.html
-Neil
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2004-10-26 12:28:44 | Re: Strange count(*) implementation? |
Previous Message | Henk Ernst Blok | 2004-10-26 11:56:41 | Re: Strange count(*) implementation? |