On Jan 19, 2006, at 06:51, Magnus Hagander wrote:
> In most cases you're going to see extremely few reads compared to
> writes
> on pg_stats, right? So why not have the backends connect to the stats
> process (or perhaps use UDP, or use the pipe, or whatever) and
> fetch the
> data when needed. So when nobody fetches any data, there is no
> overhead
> (except for the stats process adding up values, of course).
Do the stats need to persist across postmaster restarts (or crashes)?
If so, then they need to be written to disk at some point, so we
can't get rid of the stats file and the frequent writes to it. Or
maybe there could be a GUC setting for persisting stats -- if it's
enabled, it works as implemented today (flushed to disk every 500ms).
If it's disabled, the stats are only stored in-memory and never
written to a file; the postmaster could automatically do an "ANALYZE"
on startup to fill the in-memory stats.
We could move the stat file writes to happen only at a checkpoint.
Backends would get up-to-date info directly from the stats process as
you described, but it would always be persisted at a checkpoint.
Those *should* be less-frequent than every half a second. :)
- Chris