{"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"}],"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"],"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":"english-manuals:5a2acbd4e07ad8671a29f9465dd3f7223139d56ab4968619de965f192244d036","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"max_locks_per_transaction","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"max_locks_per_transaction","SourceRevision":"english-manuals:5a2acbd4e07ad8671a29f9465dd3f7223139d56ab4968619de965f192244d036","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.","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","unit":null,"vartype":"integer"},"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":"english-manuals:5a2acbd4e07ad8671a29f9465dd3f7223139d56ab4968619de965f192244d036","ContentHash":"addded56399be68b72fad58ed385939e60bc521a9f2613f877305ef756db213c","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":"zh-Hans","Fallback":true,"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"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
