Stopping the server safely and quickly
There are several modes to stop the server, depending on the level of urgency. We'll do a comparison in view of the effects in each mode.
How to do it...
We provide two variants: with and without systemd. This is similar to the previous recipe, Starting the database server manually, to which we refer to for further information. For example, what is the exact name of the systemd service unit for a given database server on a given GNU/Linux distribution?
When using systemd, you can stop PostgreSQL using the fast mode by issuing the following after having replaced SERVICEUNIT with the appropriate systemd service unit name:
sudo systemctl stop SERVICEUNITIf systemd is not available, and you are using Debian or Ubuntu, the command is as in the following example, which applies to the default 9.6 instance:
pg_ctlcluster 9.6 main stop -m fastThe fast mode is the default since PostgreSQL 9.5; the previous default was to use the smart mode, meaning wait for all users...