{"Entry":{"collection":"guc","key":"max_locks_per_transaction","name":"max_locks_per_transaction","aliases":[],"metadata":{"baseline":true,"boot_human":"Not specified","boot_val":null,"category":"Lock Management","category_zh":"","changed_in":["16","17","19"],"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.3","status":"changed","to":"8.4"},{"documentation_changed":true,"fields":{},"from":"8.4","status":"changed","to":"9.0"},{"documentation_changed":true,"fields":{},"from":"9.2","status":"changed","to":"9.3"},{"documentation_changed":true,"fields":{},"from":"9.4","status":"changed","to":"9.5"},{"documentation_changed":true,"fields":{},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{"extra_desc":{"from":"The shared lock table is sized on the assumption that at most max_locks_per_transaction * max_connections distinct objects will need to be locked at any one time.","to":"The shared lock table is sized on the assumption that at most max_locks_per_transaction objects per server process or prepared transaction will need to be locked at any one time."}},"from":"15","status":"changed","to":"16"},{"documentation_changed":false,"fields":{"extra_desc":{"from":"The shared lock table is sized on the assumption that at most max_locks_per_transaction objects per server process or prepared transaction will need to be locked at any one time.","to":"The shared lock table is sized on the assumption that at most \"max_locks_per_transaction\" objects per server process or prepared transaction will need to be locked at any one time."}},"from":"16","status":"changed","to":"17"},{"documentation_changed":true,"fields":{"boot_val":{"from":"64","to":"128"}},"from":"18","status":"changed","to":"19"},{"documentation_changed":true,"fields":{},"from":"19","status":"changed","to":"20"}],"content_hash":"b7a1507d3714a22908013a21f98ce0aa8ff431ec17665e2abf4d5ba95bae15b1","context":"","default_changed_in":["19"],"default_history":[{"from":"9.0","to":"18","value":"64"},{"from":"19","to":"19","value":"128"}],"derived_content_hash":"ad0e9a25ccfacf90b11c8a844440920e4e2c43c170f6b1f120eb6640f4866936","editorial":{"advice":{"olap":"Partitioned queries, bulk DDL, and SERIALIZABLE reports may touch many objects; test the worst plan, not only an average transaction.","oltp":"Calibrate max_locks_per_transaction from lock-wait logs, objects touched, and the concurrency bound. Fix long transactions and access ordering before adding shared memory or changing detection granularity.","small":"Defaults are usually sufficient. If raising a startup lock-table setting, account for max_connections, prepared transactions, and standby consistency together."},"mechanism":["Sets the maximum number of locks per transaction. The value is fixed when the server starts, so changing it requires a restart.","The shared lock table is sized for this average number of distinct lockable objects per backend or prepared transaction. A single transaction may exceed the number if space remains; it does not limit row locks, and standbys need a value at least as large as the primary.","Monitor and change max_locks_per_transaction together with deadlock_timeout, log_lock_waits, lock_timeout. Validate on the relevant server role and real workload, then use its postmaster context to choose session change, reload, or restart; a historical boot default is not the current effective value."],"pitfalls":["Reading it as a row-lock limit or a hard limit for one transaction.","Raising it without accounting for max_connections and prepared transactions.","Setting a standby below its primary and preventing standby queries.","Reading an average shared-memory sizing value as a hard per-transaction limit.","Raising it without the multiplier from connections and prepared transactions."],"references":[{"title":"PostgreSQL 19 Beta 4: max_locks_per_transaction","url":"https://www.postgresql.org/docs/19/runtime-config-locks.html#GUC-MAX-LOCKS-PER-TRANSACTION"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["deadlock_timeout","log_lock_waits","lock_timeout","max_pred_locks_per_transaction","max_pred_locks_per_relation","max_pred_locks_per_page"],"summary":"max_locks_per_transaction — Sets the maximum number of locks per transaction. Observed in PG9.0–19 Beta 4; its last measured boot default is 128 in PG19 Beta 4, with postmaster context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"7.4","group":"Lock Management","group_slug":"locks","imported_at":"2026-09-27T17:57:31.701416+08:00","intro_commit":{},"key":"max_locks_per_transaction","last_version":"20","max_val":"","min_val":"","name":"max_locks_per_transaction","position":270,"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"],"repair_provenance":{"original_source_revision":"english-manuals:5a2acbd4e07ad8671a29f9465dd3f7223139d56ab4968619de965f192244d036","receipt_sha256":"e4595c0fef4252eecdc71c600836a790c2523368b3d796b24c7688d4f7abfb05","repair":"wiki-repair-20261023"},"short_desc":"The shared lock table has space for max_locks_per_transaction objects (e.g., tables) per server process or prepared transaction; hence, no more than this many distinct objects can be locked at any one time.","short_desc_zh":"","source_rev":"wiki-repair-20261023:6efac231a1d9e46aad38e34e0d499ab8411c4f72cf99ec38e51f319fb898e0b9","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"max_locks_per_transaction","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"max_locks_per_transaction","SourceRevision":"wiki-repair-20261023:6efac231a1d9e46aad38e34e0d499ab8411c4f72cf99ec38e51f319fb898e0b9","Facts":{"boot_val":"64","category":"Lock Management","context":"postmaster","description":"The shared lock table has space for max_locks_per_transaction objects (e.g., tables) per server process or prepared transaction; hence, no more than this many distinct objects can be locked at any one time. This parameter limits the average number of object locks used by each transaction; individual transactions can lock more objects as long as the locks of all transactions fit in the lock table. This is not the number of rows that can be locked; that value is unlimited. The default, 64, has historically proven sufficient, but you might need to raise this value if you have queries that touch many different tables in a single transaction, e.g., query of a parent table with many children. This parameter can only be set at server start. When running a standby server, you must set this parameter to have the same or higher value as on the primary server. Otherwise, queries will not be allowed in the standby server.","description_zh":"共享锁表为每个服务器进程或预备事务预留可容纳 max_locks_per_transaction 个对象（例如表）的空间；因此，在任何时刻可被锁住的不同对象数都不能超过总容量。这个参数限制每个事务使用的对象锁的平均数量；只要所有事务的锁能放入锁表中，单个事务就可以锁住更多对象。这不是能被锁住的行数，那个值是没有限制的。默认值 64 已经被历史证明是足够的，但是如果你有需要在一个事务中使用很多不同表的查询（例如查询一个有很多子表的父表），你可能需要提高这个值。这个参数只能在服务器启动时设置。 运行备库时，必须将此参数设置为大于或等于主库上的值。否则，备库上将不允许查询。","description_zh_html":"\u003cp\u003e\n        共享锁表为每个服务器进程或预备事务预留可容纳 \u003ccode class=\"varname\"\u003emax_locks_per_transaction\u003c/code\u003e 个对象（例如表）的空间；因此，在任何时刻可被锁住的不同对象数都不能超过总容量。这个参数限制每个事务使用的对象锁的平均数量；只要所有事务的锁能放入锁表中，单个事务就可以锁住更多对象。这\u003cspan class=\"emphasis\"\u003e\u003cem\u003e不\u003c/em\u003e\u003c/span\u003e是能被锁住的行数，那个值是没有限制的。默认值 64 已经被历史证明是足够的，但是如果你有需要在一个事务中使用很多不同表的查询（例如查询一个有很多子表的父表），你可能需要提高这个值。这个参数只能在服务器启动时设置。\n       \u003c/p\u003e\u003cp\u003e\n        运行备库时，必须将此参数设置为大于或等于主库上的值。否则，备库上将不允许查询。\n       \u003c/p\u003e","doc":{"anchor":"GUC-MAX-LOCKS-PER-TRANSACTION","file":"runtime-config-locks.html","lang":"en","sha256":"5faab37986a9ca9ff362569c12b8c63e8df57c76c9aea6e40d06e44e9abee87b","slug":"18"},"documented":true,"enumvals":null,"extra_desc":"The shared lock table is sized on the assumption that at most \"max_locks_per_transaction\" objects per server process or prepared transaction will need to be locked at any one time.","lang":"en","max_val":"2147483647","metadata_version":"18","min_val":"10","name":"max_locks_per_transaction","short_desc":"Sets the maximum number of locks per transaction.","source":"pg-settings-source-snapshot","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/runtime-config-locks.html","sha256":"57e70ce1a9664a1043a2a4b3489f8fe2ca9fb65ddd7f71cb527c8fb1c1035b1f"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"unit":null,"vartype":"integer","zh_from":"same-version-pgdoc"},"ManualEvidence":{"doc":{"anchor":"GUC-MAX-LOCKS-PER-TRANSACTION","file":"runtime-config-locks.html","lang":"en","sha256":"5faab37986a9ca9ff362569c12b8c63e8df57c76c9aea6e40d06e44e9abee87b","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"max_locks_per_transaction","SourceDatabase":"center","Version":"18","Locale":"en","Title":"max_locks_per_transaction","Summary":"The shared lock table has space for max_locks_per_transaction objects (e.g., tables) per server process or prepared transaction; hence, no more than this many distinct objects can be locked at any one time. This parameter limits the average number of object locks used by each transaction; individual transactions can lock more objects as long as the locks of all transactions fit in the lock table. This is not the number of rows that can be locked; that value is unlimited. The default, 64, has historically proven sufficient, but you might need to raise this value if you have queries that touch many different tables in a single transaction, e.g., query of a parent table with many children. This parameter can only be set at server start. When running a standby server, you must set this parameter to have the same or higher value as on the primary server. Otherwise, queries will not be allowed in the standby server.","BodyHTML":"\u003cp\u003eThe shared lock table has space for max_locks_per_transaction objects (e.g., tables) per server process or prepared transaction; hence, no more than this many distinct objects can be locked at any one time. This parameter limits the average number of object locks used by each transaction; individual transactions can lock more objects as long as the locks of all transactions fit in the lock table. This is not the number of rows that can be locked; that value is unlimited. The default, 64, has historically proven sufficient, but you might need to raise this value if you have queries that touch many different tables in a single transaction, e.g., query of a parent table with many children. This parameter can only be set at server start. When running a standby server, you must set this parameter to have the same or higher value as on the primary server. Otherwise, queries will not be allowed in the standby server.\u003c/p\u003e","SourceRevision":"wiki-repair-20261023:6efac231a1d9e46aad38e34e0d499ab8411c4f72cf99ec38e51f319fb898e0b9","ContentHash":"a5726dc30c869caf5f65b31a1959eead724c5fdc0db0eb3f02fdd2709bdef982","Payload":{"description":"The shared lock table has space for max_locks_per_transaction objects (e.g., tables) per server process or prepared transaction; hence, no more than this many distinct objects can be locked at any one time. This parameter limits the average number of object locks used by each transaction; individual transactions can lock more objects as long as the locks of all transactions fit in the lock table. This is not the number of rows that can be locked; that value is unlimited. The default, 64, has historically proven sufficient, but you might need to raise this value if you have queries that touch many different tables in a single transaction, e.g., query of a parent table with many children. This parameter can only be set at server start. When running a standby server, you must set this parameter to have the same or higher value as on the primary server. Otherwise, queries will not be allowed in the standby server."}},"RequestedLocale":"en","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}
