DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Client Connection Defaults / Shared Library Preloading

shared_preload_libraries

Lists shared libraries to preload into server.

  • Default: '' (empty)
  • Type: string
  • Applies: Restart required

In plain words

Libraries listed here are loaded by the postmaster when the server starts, before any client connects. Some extensions, like pg_stat_statements, only work this way because they need to reserve shared memory or start background processes at startup.

Changing it needs a restart, and a typo means the server will not start.

For DBAs and operators

The postmaster loads each library at startup and runs its _PG_init(), where it can request shared memory, LWLocks, register hooks and background workers. Child processes inherit the loaded library through fork(), so backends start without reloading it. On Windows every process reloads all preload libraries.

Without it, such extensions fail at use time: ERROR: pg_stat_statements must be loaded via "shared_preload_libraries". With a missing file the server refuses to start (FATAL: could not access file "pg_stat_statments": No such file or directory); always check the spelling (postgres -C shared_preload_libraries prints the configured value, but does not load the libraries) and that each file exists in $libdir before restarting a production server.

Common entries: pg_stat_statements, auto_explain, pg_cron, pg_prewarm, pgaudit, timescaledb, pg_stat_monitor (Percona). The value is a comma-separated list; ALTER SYSTEM SET shared_preload_libraries = 'a,b' replaces the whole list, so include existing entries. Pending changes show pending_restart = true in pg_settings.

How to change it

Change in postgresql.conf or ALTER SYSTEM, then restart the server.

See it in context

Postmaster Memory architecture

Related parameters

session_preload_libraries local_preload_libraries dynamic_library_path max_worker_processes

All Client Connection Defaults parameters