brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: pg_settings.pending_restart lists PostgreSQL changes that still need a restart

Postgresql
~/tips/tip-postgresql-pg-settings-pending-restart

FROM pg_settings

Shows which edited settings in the config file are not active yet because the server has to restart.

I edit a config file, reload, and then wonder whether the setting is live. For some settings the answer is no, and PostgreSQL will tell you which ones if you ask the right view.

SELECT name, setting, context, sourcefile, sourceline
FROM pg_settings
WHERE pending_restart;

The pending_restart column is true when a value was changed in the configuration file but needs a restart to take effect. An empty result means everything you edited is already active.

The context column explains why. postmaster means the setting is only read at server start, for example shared_buffers. sighup means a reload is enough, either SELECT pg_reload_conf(); or a SIGHUP to the postmaster. user settings can even be changed per session with SET.

sourcefile and sourceline point at the file and line that set the current value, which helps a lot when the config uses include directives. A caveat: those two columns are NULL for users who are not a superuser and have no pg_read_all_settings privilege, so run it as an admin account.

The docs list more context values. internal settings cannot be changed directly, and backend or superuser-backend settings can be set in a connection request but never change in a session once it has started. The view can also be updated: an UPDATE on a row of pg_settings is equivalent to SET for that parameter, and only affects your current session.

Further reading: pg_settings

More Postgresql tips FROM pg_hba_file_rules LOAD 'auto_explain'; CREATE EXTENSION pgstattuple; pg_dump -O -x -f mydb.sql mydb FROM pg_stat_user_indexes All Postgresql tips (24) All topics

Link