Skip to Main Content
PostgreSQL 10 High Performance - Third Edition
book

PostgreSQL 10 High Performance - Third Edition

by Enrico Pirozzi
April 2018
Intermediate to advanced content levelIntermediate to advanced
508 pages
15h 22m
English
Packt Publishing
Content preview from PostgreSQL 10 High Performance - Third Edition

Saving pg_stat_bgwriter snapshots

In order for this data to really be interesting, you need to save periodic snapshots of it with an associated timestamp. It's easy to create a table for that purpose and put a first snapshot into it:

    pgbench=# CREATE TABLE pg_stat_bgwriter_snapshot AS SELECT current_timestamp,* FROM pg_stat_bgwriter;
    SELECT 1
    pgbench=# INSERT INTO pg_stat_bgwriter_snapshot (SELECT current_timestamp,* FROM pg_stat_bgwriter);
  

Now you can wait until some time has passed, with a representative chunk of activity; at least an hour is recommended, preferably a day. Insert a second snapshot into that table:

    pgbench=# INSERT INTO pg_stat_bgwriter_snapshot (SELECT current_timestamp,* FROM pg_stat_bgwriter);
  

And now it's possible ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PostgreSQL: Up and Running, 3rd Edition

PostgreSQL: Up and Running, 3rd Edition

Regina O. Obe, Leo S. Hsu
Learn PostgreSQL - Second Edition

Learn PostgreSQL - Second Edition

Luca Ferrari, Enrico Pirozzi
PostgreSQL, Second Edition

PostgreSQL, Second Edition

Korry Douglas, Susan Douglas

Publisher Resources

ISBN: 9781788474481Supplemental Content