How to do it...

Assuming our logs are located at /db/pgdata/pg_log, follow these steps to examine the checkpoint activity:

  1. Execute this command to find the most recent logfile:
        ls -lt /db/pgdata/pg_log/postgres*.log | head -n 1
  1. If the latest log is named postgresql-2016-10-16.log, view all the checkpoints in this log with the following command:
        grep checkpoint /db/pgdata/pg_log/postgresql-2016-10-16.log
  1. Execute the following command to obtain the five longest disk syncs:
        grep 'checkpoint complete:' \
            /db/pgdata/pg_log/postgresql-2016-10-16.log \
            | sed 's/.* sync=/sync=/; s/total=.*; //;' \
            | sort -n | tail -n 5

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.