Re: stats reset during pg_restore?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux