{"Entry":{"collection":"guc","key":"log_lock_waits","name":"log_lock_waits","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Reporting and Logging / What to Log","category_zh":"","changed_in":["19"],"changes":[{"documentation_changed":false,"fields":{},"from":"8.2","status":"added","to":"8.3"},{"documentation_changed":true,"fields":{},"from":"9.1","status":"changed","to":"9.2"},{"documentation_changed":true,"fields":{},"from":"14","status":"changed","to":"15"},{"documentation_changed":true,"fields":{"boot_val":{"from":"off","to":"on"}},"from":"18","status":"changed","to":"19"}],"content_hash":"2e90cd098df68fb44ced4a9fc265c0c819dd7fc4fcb402ab2667c6203fa36f81","context":"","default_changed_in":["19"],"default_history":[{"from":"9.0","to":"18","value":"off"},{"from":"19","to":"19","value":"on"}],"editorial":{"advice":{"olap":"Analytical jobs can justify richer log_lock_waits telemetry, but account for long statements, large bind values, and bursty completion patterns in the log pipeline.","oltp":"Tune log_lock_waits against an explicit observability question and a measured log-volume budget. Prefer selective thresholds, sampling, or role-level overrides over indiscriminate capture.","small":"Keep log_lock_waits useful but bounded: verify disk, collector, retention, and redaction capacity before increasing detail or frequency."},"mechanism":["log_lock_waits logs long lock waits. A wait is logged after deadlock_timeout, so the diagnostic threshold and deadlock detector cadence are coupled.","log_lock_waits is a SUPERUSER-context setting. Superuser or a role granted the appropriate SET privilege can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.","It changes emitted diagnostic data rather than query semantics, but volume, sensitive content, log_line_prefix, destinations, collector throughput, and retention determine operational cost and usefulness."],"pitfalls":["Changing log_lock_waits in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.","Enabling richer logging without budgeting collector throughput, storage, retention, and downstream query cost.","Writing SQL text, bind values, identities, or host data without a redaction and access-control policy.","Changing deadlock_timeout without realizing it also changes when lock-wait diagnostics appear."],"references":[{"title":"PostgreSQL 19 Beta 4: log_lock_waits","url":"https://www.postgresql.org/docs/19/runtime-config-logging.html#GUC-LOG-LOCK-WAITS"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["log_checkpoints","log_autovacuum_min_duration","log_lock_failures","log_temp_files","log_replication_commands"],"summary":"log_lock_waits is the PostgreSQL setting that controls whether PostgreSQL logs long lock waits."},"enumvals":[],"first_version":"8.3","group":"Reporting and Logging","group_slug":"logging","imported_at":"2026-09-30T00:40:57.365145+08:00","intro_commit":{},"key":"log_lock_waits","last_version":"20","max_val":"","min_val":"","name":"log_lock_waits","position":232,"present_in":["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":"Controls whether a log message is produced when a session waits longer than deadlock_timeout to acquire a lock.","short_desc_zh":"","source_rev":"english-manuals:a78d777e4957b4178ae99fe3dce5b65be544c68e22b6c32847954b7d6e6db998","unit":"","vartype":"bool"}},"Definition":{"Collection":"guc","Key":"log_lock_waits","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"log_lock_waits","SourceRevision":"english-manuals:a78d777e4957b4178ae99fe3dce5b65be544c68e22b6c32847954b7d6e6db998","Facts":{"boot_val":"off","category":"Reporting and Logging / What to Log","context":"superuser","description":"Controls whether a log message is produced when a session waits longer than deadlock_timeout to acquire a lock. This is useful in determining if lock waits are causing poor performance. The default is off. Only superusers and users with the appropriate SET privilege can change this setting.","doc":{"anchor":"GUC-LOG-LOCK-WAITS","file":"runtime-config-logging.html","lang":"en","sha256":"93c48c522a72fca19705c4c91a71e951eae653662008eee2e4a9a74a11127fde","slug":"18"},"documented":true,"enumvals":null,"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"log_lock_waits","short_desc":"Logs long lock waits.","source":"pg-settings-source-snapshot","unit":null,"vartype":"bool"},"ManualEvidence":{"doc":{"anchor":"GUC-LOG-LOCK-WAITS","file":"runtime-config-logging.html","lang":"en","sha256":"93c48c522a72fca19705c4c91a71e951eae653662008eee2e4a9a74a11127fde","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"log_lock_waits","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"log_lock_waits","Summary":"","BodyHTML":"\u003cp\u003e控制会话为获取锁而等待的时间超过\u003ca href=\"/docs/18/runtime-config-locks.html#GUC-DEADLOCK-TIMEOUT\" rel=\"nofollow\"\u003edeadlock_timeout\u003c/a\u003e时是否生成日志消息。这对于确定锁等待是否导致性能不佳很有用。默认值为\u003ccode\u003eoff\u003c/code\u003e。只有超级用户和具有适当\u003ccode\u003eSET\u003c/code\u003e权限的用户才能更改此设置。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"cc99fd3b2dcc25cdffdf49669e608a4983b7a052aa494e606ea20eb50b22d4c7","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e控制会话为获取锁而等待的时间超过\u003ca href=\"/docs/18/runtime-config-locks.html#GUC-DEADLOCK-TIMEOUT\"\u003edeadlock_timeout\u003c/a\u003e时是否生成日志消息。这对于确定锁等待是否导致性能不佳很有用。默认值为\u003ccode class=\"literal\"\u003eoff\u003c/code\u003e。只有超级用户和具有适当\u003ccode class=\"literal\"\u003eSET\u003c/code\u003e权限的用户才能更改此设置。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","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}
