DATABASE TECHNICAL PAPER

Faster shutdowns with checkpoint

2018-01-10 Greg Clough

Have you ever restarted your PostgreSQL cluster and wondered why it’s taking so long? The cause of this is generally one of these:

  • You didn’t include the “-m fast” flag (v9.4 and earlier), and sessions are still connected
  • A large update query is rolling back
  • There are a large number of dirty blocks, which are not yet written to disk

If you run a manual “CHECKPOINT” immediately prior to running the shutdown, then you can sometimes drastically shorten the time a restart takes:

postgres@localhost[default:5432] ~/$ psql -c CHECKPOINT && pg_ctl restart -m fast

Leave a Reply

Discover more from Greg Clough's notes on PostgreSQL

Subscribe now to keep reading and get access to the full archive.

Continue reading