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
---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]