Re: stats reset during pg_restore? - Mailing list pgsql-performance

From Alvaro Herrera
Subject Re: stats reset during pg_restore?
Date
Msg-id 20060827143754.GA13665@alvh.no-ip.org
Whole thread Raw
In response to Re: stats reset during pg_restore?  ("George Pavlov" <gpavlov@mynewplace.com>)
List pgsql-performance
George Pavlov wrote:

> Based on how it works it seems that a server crash might lose the
> in-memory stats data as well?

Yeah, IIRC the postmaster removes the stat file after crash recovery.
It doesn't check the file for correctness.

> I imagine PITR does not take care of that special file (where is it
> by, by the way?). I have not worked with replication (yet), but I
> imagine replica databases will also be agnostic of the master's stats?

Neither PITR nor the replication systems I know about do anything about
the stats.

The file is $PGDATA/global/pgstat.stat

The code to read it, which is at the same time the documentation to its
format, is in src/backend/postmaster/pgstat.c, function
pgstat_read_statfile.  It's quite simple.  I think you could read it in
Perl if you wanted; and rewrite the file again after a restore (you'd
need to change the Oids in the table entries, etc).

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-performance by date:

Previous
From: "George Pavlov"
Date:
Subject: Re: stats reset during pg_restore?
Next
From: "George Pavlov"
Date:
Subject: Re: [8.1.4] Help optimizing query