> Alvaro Herrera <[EMAIL PROTECTED]> writes: > > Maybe the fact that the stat file is completely rewritten > every 500 ms > > should be reconsidered, if in the future someone chooses to rewrite > > the stat system. We can reconsider this part then, as well. > > Yeah, it's becoming pretty obvious that that design does not > scale very well. I don't immediately have any ideas about a > better way though. > > I am working on some marginal hacks like not writing more of > the backend activity strings than is needed, but it'd be > nicer to think of a different solution.
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). Then you could also push down some filtering to the stats process - for example, when you are reading from pg_stat_activity there is no need to send over the row level stats. IIRC, today you have to read (and write) the whole stats file anyways. //Magnus ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings