Type: | integer |
Default: | 100 |
Min: | 1 |
Max: | 262143 |
Context: | postmaster |
Restart: | true |
Determines the maximum number of concurrent connections to the database server. The default is typically 100 connections, but might be less if your kernel settings will not support it (as determined during initdb). This parameter can only be set at server start.
PostgreSQL sizes certain resources based directly on the value of max_connections
. Increasing its value leads to higher allocation of those resources, including shared memory.
When running a standby server, you must set this parameter to the same or higher value than on the primary server. Otherwise, queries will not be allowed in the standby server.
Recommendations
Should be set to the maximum number of connections which you expect to need at peak load. Note that each connection uses shared_buffer memory, as well as additional non-shared memory, so be careful not to run the system out of memory. In general, if you need more than 200 connections, you should probably be making more use of connection pooling.
On StackOverflow
On pgsql-hackers
- Re: scalability bottlenecks with (many) partitions (and more)
- failed optimization attempt for ProcArrayGroupClearXid(): using custom PGSemaphores that use __atomics and futexes batching via IO_URING
- Re: Cygwin support
- Refactor GetLockStatusData() by skipping unused backends and groups
- Re: Refactor GetLockStatusData() by skipping unused backends and groups