{"Entry":{"collection":"guc","key":"max_connections","name":"max_connections","aliases":[],"metadata":{"baseline":true,"boot_human":"Not specified","boot_val":null,"category":"Connections and Authentication / Connection Settings","category_zh":"","changed_in":["9.1","9.6"],"changes":[{"documentation_changed":true,"fields":{},"from":"7.4","status":"changed","to":"8.0"},{"documentation_changed":true,"fields":{},"from":"8.0","status":"changed","to":"8.1"},{"documentation_changed":true,"fields":{},"from":"8.1","status":"changed","to":"8.2"},{"documentation_changed":true,"fields":{},"from":"8.2","status":"changed","to":"8.3"},{"documentation_changed":true,"fields":{},"from":"8.4","status":"changed","to":"9.0"},{"documentation_changed":false,"fields":{"max_val":{"from":"536870911","to":"8388607"}},"from":"9.0","status":"changed","to":"9.1"},{"documentation_changed":true,"fields":{},"from":"9.2","status":"changed","to":"9.3"},{"documentation_changed":false,"fields":{"max_val":{"from":"8388607","to":"262143"}},"from":"9.5","status":"changed","to":"9.6"},{"documentation_changed":true,"fields":{},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{},"from":"16","status":"changed","to":"17"},{"documentation_changed":true,"fields":{},"from":"19","status":"changed","to":"20"}],"content_hash":"7bfd8c70de4cc4dfd5c7a005fbf78400f2bc606a1de051efc0a82eadd672c7b5","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"100"}],"editorial":{"advice":{"olap":"Analytical sessions are usually fewer and heavier; keep the backend ceiling low enough that simultaneous work_mem and parallel-worker demand remain bounded. Reserve explicit capacity for ETL and administration.","oltp":"Prefer transaction pooling for large client populations and size PostgreSQL backends for peak active database work plus monitoring, maintenance, and failover margin. Do not map one client connection to one server slot by default.","small":"Use a low ceiling with a pooler and preserve reserved slots. Validate startup shared-memory requirements and do not compensate for connection leaks by repeatedly raising the limit."},"mechanism":["max_connections limits concurrent database-server connections and can only be changed at server start. PostgreSQL sizes some resources directly from it, so raising the ceiling increases allocations including shared memory even when not all slots are busy.","reserved_connections and superuser_reserved_connections carve emergency or privileged capacity out of the same overall ceiling. An application therefore cannot normally consume every configured slot.","A standby must use a value at least as high as its primary. Connection pooling can decouple large client populations from a smaller, controlled number of PostgreSQL backends."],"pitfalls":["Changing the value without planning a restart and keeping standbys at least as high as the primary.","Ignoring shared-memory and per-backend overhead created by a higher ceiling.","Forgetting reserved and superuser-reserved slots when calculating application capacity.","Combining a high connection ceiling with generous per-operation memory settings and assuming the product cannot occur."],"references":[{"title":"PostgreSQL 19 Beta 4: max_connections","url":"https://www.postgresql.org/docs/19/runtime-config-connection.html#GUC-MAX-CONNECTIONS"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["reserved_connections","superuser_reserved_connections","work_mem","max_worker_processes","max_prepared_transactions","max_wal_senders"],"summary":"The startup-time ceiling on concurrent PostgreSQL client connections and a sizing input for several shared resources."},"enumvals":[],"first_version":"7.4","group":"Connections and Authentication","group_slug":"connection","imported_at":"2026-09-27T17:57:31.67395+08:00","intro_commit":{},"key":"max_connections","last_version":"20","max_val":"","min_val":"","name":"max_connections","position":262,"present_in":["7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"short_desc":"Determines the maximum number of concurrent connections to the database server.","short_desc_zh":"","source_rev":"english-manuals:eb3142d88d2e4678fa7c215a7cdeff2946fe06cba48b2f6cf4d1d5ae0ca265f3","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"max_connections","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"max_connections","SourceRevision":"english-manuals:eb3142d88d2e4678fa7c215a7cdeff2946fe06cba48b2f6cf4d1d5ae0ca265f3","Facts":{"boot_val":"100","category":"Connections and Authentication / Connection Settings","context":"postmaster","description":"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.","doc":{"anchor":"GUC-MAX-CONNECTIONS","file":"runtime-config-connection.html","lang":"en","sha256":"567ba928f3e4c4783f548dc8a54f1e748f02bbe163924605f2132eb5b0da440d","slug":"18"},"documented":true,"enumvals":null,"extra_desc":null,"lang":"en","max_val":"262143","metadata_version":"18","min_val":"1","name":"max_connections","short_desc":"Sets the maximum number of concurrent connections.","source":"pg-settings-source-snapshot","unit":null,"vartype":"integer"},"ManualEvidence":{"doc":{"anchor":"GUC-MAX-CONNECTIONS","file":"runtime-config-connection.html","lang":"en","sha256":"567ba928f3e4c4783f548dc8a54f1e748f02bbe163924605f2132eb5b0da440d","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"max_connections","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"max_connections","Summary":"","BodyHTML":"\u003cp\u003e决定数据库服务器允许的最大并发连接数。默认值通常是 100 个连接，但如果内核设置不支持（在 \u003cspan\u003einitdb\u003c/span\u003e 期间确定），则可能更少。这个参数只能在服务器启动时设置。\u003c/p\u003e\u003cp\u003e\u003cspan\u003ePostgreSQL\u003c/span\u003e 会直接根据 \u003ccode\u003emax_connections\u003c/code\u003e 的值来确定某些资源的规模。增大该值会导致这些资源（包括共享内存）的分配随之增加。\u003c/p\u003e\u003cp\u003e当运行一个备库时，你必须设置这个参数等于或大于主库上的参数。否则，备库上将不允许查询。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"d8a931a320bea9f89f6dda009520fd112c89355f8c31ccc5ce191763bb122e12","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e决定数据库服务器允许的最大并发连接数。默认值通常是 100 个连接，但如果内核设置不支持（在 \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e 期间确定），则可能更少。这个参数只能在服务器启动时设置。\u003c/p\u003e\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 会直接根据 \u003ccode class=\"varname\"\u003emax_connections\u003c/code\u003e 的值来确定某些资源的规模。增大该值会导致这些资源（包括共享内存）的分配随之增加。\u003c/p\u003e\u003cp\u003e当运行一个备库时，你必须设置这个参数等于或大于主库上的参数。否则，备库上将不允许查询。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
