{"Entry":{"collection":"guc","key":"wal_level","name":"wal_level","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Write-Ahead Log / Settings","category_zh":"","changed_in":["9.4","9.6","10","14"],"changes":[{"documentation_changed":false,"fields":{},"from":"8.4","status":"added","to":"9.0"},{"documentation_changed":true,"fields":{"enumvals":{"from":["minimal","archive","hot_standby"],"to":["minimal","archive","hot_standby","logical"]}},"from":"9.3","status":"changed","to":"9.4"},{"documentation_changed":true,"fields":{},"from":"9.4","status":"changed","to":"9.5"},{"documentation_changed":true,"fields":{"enumvals":{"from":["minimal","archive","hot_standby","logical"],"to":["minimal","replica","logical"]}},"from":"9.5","status":"changed","to":"9.6"},{"documentation_changed":true,"fields":{"boot_val":{"from":"minimal","to":"replica"}},"from":"9.6","status":"changed","to":"10"},{"documentation_changed":true,"fields":{},"from":"12","status":"changed","to":"13"},{"documentation_changed":true,"fields":{"short_desc":{"from":"Set the level of information written to the WAL.","to":"Sets the level of information written to the WAL."}},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{},"from":"18","status":"changed","to":"19"}],"content_hash":"53999aa50d0afd45f0669b54e0c80a2a60eabdeab6cc0d8c428766a8b8db53ff","context":"","default_changed_in":["10"],"default_history":[{"from":"9.0","to":"9.6","value":"minimal"},{"from":"10","to":"19","value":"replica"}],"editorial":{"advice":{"olap":"Provision WAL, archive bandwidth, and recovery I/O for bulk-load peaks. Coordinate load pacing and checkpoints when reducing spikes; never break the recovery chain for throughput.","oltp":"Establish durability and recovery objectives first, then tune wal_level from WAL rate, flush latency, checkpoints, and peak pg_wal usage. Validate every change with crash/recovery and archive monitoring.","small":"Start from safe defaults and set explicit alerts for limited disk capacity. Do not disable durability or break the recovery chain merely to save modest I/O."},"mechanism":["Sets the level of information written to the WAL. The value is fixed when the server starts, so changing it requires a restart.","minimal logs only crash-recovery needs and is incompatible with archiving/streaming modes that require replica data; replica supports physical replication and archive recovery; logical adds logical-decoding information. Changing level requires restart and may change WAL volume.","Monitor and change wal_level together with wal_compression, full_page_writes, wal_log_hints. 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":["Selecting minimal while expecting archiving, streaming replication, or logical decoding.","Raising it without budgeting extra WAL and restart downtime.","Lowering it while slots/subscriptions still depend on the higher level.","Confusing pg_settings base units with human-readable configuration units.","Benchmarking throughput without a crash-recovery and archive-restore test."],"references":[{"title":"PostgreSQL 19 Beta 4: wal_level","url":"https://www.postgresql.org/docs/19/runtime-config-wal.html#GUC-WAL-LEVEL"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["wal_compression","full_page_writes","wal_log_hints","wal_buffers","max_wal_senders","max_replication_slots"],"summary":"wal_level — Sets the level of information written to the WAL. Observed in PG9.0–19 Beta 4; its last measured boot default is replica in PG19 Beta 4, with postmaster context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"9.0","group":"Write-Ahead Log","group_slug":"wal","imported_at":"2026-09-27T17:57:32.340563+08:00","intro_commit":{},"key":"wal_level","last_version":"20","max_val":"","min_val":"","name":"wal_level","position":471,"present_in":["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":"wal_level determines how much information is written to the WAL.","short_desc_zh":"","source_rev":"english-manuals:f3739c9193b8aba5d64bc752adcfdac035a0aa826ea6ef4fe2252ed93d55c881","unit":"","vartype":"enum"}},"Definition":{"Collection":"guc","Key":"wal_level","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"wal_level","SourceRevision":"english-manuals:f3739c9193b8aba5d64bc752adcfdac035a0aa826ea6ef4fe2252ed93d55c881","Facts":{"boot_val":"replica","category":"Write-Ahead Log / Settings","context":"postmaster","description":"wal_level determines how much information is written to the WAL. The default value is replica, which writes enough data to support WAL archiving and replication, including running read-only queries on a standby server. minimal removes all logging except the information required to recover from a crash or immediate shutdown. Finally, logical adds information necessary to support logical decoding. Each level includes the information logged at all lower levels. This parameter can only be set at server start. The minimal level generates the least WAL volume. It logs no row information for permanent relations in transactions that create or rewrite them. This can make operations much faster (see Section 14.4.7). Operations that initiate this optimization include: ALTER ... SET TABLESPACE CLUSTER CREATE TABLE REFRESH MATERIALIZED VIEW (without CONCURRENTLY) REINDEX TRUNCATE However, minimal WAL does not contain sufficient information for point-in-time recovery, so replica or higher must be used to enable continuous archiving (archive_mode) and streaming binary replication. In fact, the server will not even start in this mode if max_wal_senders is non-zero. Note that changing wal_level to minimal makes previous base backups unusable for point-in-time recovery and standby servers. In logical level, the same information is logged as with replica, plus information needed to extract logical change sets from the WAL. Using a level of logical will increase the WAL volume, particularly if many tables are configured for REPLICA IDENTITY FULL and many UPDATE and DELETE statements are executed. In releases prior to 9.6, this parameter also allowed the values archive and hot_standby. These are still accepted but mapped to replica.","doc":{"anchor":"GUC-WAL-LEVEL","file":"runtime-config-wal.html","lang":"en","sha256":"d2646404a06e8f7ac655204b4f28c049ae8f3fd4f2272db080fcefa2c4af0763","slug":"18"},"documented":true,"enumvals":["minimal","replica","logical"],"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"wal_level","short_desc":"Sets the level of information written to the WAL.","source":"pg-settings-source-snapshot","unit":null,"vartype":"enum"},"ManualEvidence":{"doc":{"anchor":"GUC-WAL-LEVEL","file":"runtime-config-wal.html","lang":"en","sha256":"d2646404a06e8f7ac655204b4f28c049ae8f3fd4f2272db080fcefa2c4af0763","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"wal_level","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"wal_level","Summary":"","BodyHTML":"\u003cp\u003e\u003ccode\u003ewal_level\u003c/code\u003e决定多少信息写入到 WAL 中。默认值是\u003ccode\u003ereplica\u003c/code\u003e，它会写入足够的数据以支持WAL归档和复制，包括在备库上运行只读查询。\u003ccode\u003eminimal\u003c/code\u003e会去掉除从崩溃或者立即关机中进行恢复所需的信息之外的所有记录。最后，\u003ccode\u003elogical\u003c/code\u003e会增加支持逻辑解码所需的信息。每个层次包括所有更低层次记录的信息。这个参数只能在服务器启动时设置。\u003c/p\u003e\u003cp\u003e\u003ccode\u003eminimal\u003c/code\u003e级别生成最少的WAL日志量。对于在当前事务中创建或重写的永久关系，不记录其行信息。这可以使操作速度更快（参见\u003ca href=\"/docs/18/populate.html#POPULATE-PITR\" rel=\"nofollow\"\u003e第 14.4.7 节\u003c/a\u003e）。触发此优化的操作包括：\u003c/p\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003eALTER ... SET TABLESPACE\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003eCLUSTER\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003eCREATE TABLE\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003eREFRESH MATERIALIZED VIEW\u003c/code\u003e（不使用\u003ccode\u003eCONCURRENTLY\u003c/code\u003e）\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003eREINDEX\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003eTRUNCATE\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003cp\u003e然而，minimal 级别的 WAL 不包含足够的信息用于时间点恢复，因此必须使用\u003ccode\u003ereplica\u003c/code\u003e或更高级别来启用持续归档（\u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-MODE\" rel=\"nofollow\"\u003earchive_mode\u003c/a\u003e）和流式二进制复制。实际上，如果\u003ccode\u003emax_wal_senders\u003c/code\u003e不为零，服务器甚至不会以此模式启动。请注意，将\u003ccode\u003ewal_level\u003c/code\u003e更改为\u003ccode\u003eminimal\u003c/code\u003e会使先前的基础备份无法用于时间点恢复和备库。\u003c/p\u003e\u003cp\u003e在\u003ccode\u003elogical\u003c/code\u003e级别上，记录与\u003ccode\u003ereplica\u003c/code\u003e相同的信息，以及从WAL中提取逻辑变更集所需的信息。使用\u003ccode\u003elogical\u003c/code\u003e级别会增加 WAL 的数量，特别是如果许多表被配置为\u003ccode\u003eREPLICA IDENTITY FULL\u003c/code\u003e，并且执行了许多\u003ccode\u003eUPDATE\u003c/code\u003e和\u003ccode\u003eDELETE\u003c/code\u003e语句。\u003c/p\u003e\u003cp\u003e在 9.6 之前的版本中，这个参数也允许值\u003ccode\u003earchive\u003c/code\u003e和\u003ccode\u003ehot_standby\u003c/code\u003e。现在仍然接受这些值，但是它们会被映射到\u003ccode\u003ereplica\u003c/code\u003e。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"dc5c8c80d34cfe5ada125a9680d825f8722becafd5c5d74c2e55983c026f5ce8","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e\u003ccode class=\"varname\"\u003ewal_level\u003c/code\u003e决定多少信息写入到 WAL 中。默认值是\u003ccode class=\"literal\"\u003ereplica\u003c/code\u003e，它会写入足够的数据以支持WAL归档和复制，包括在备库上运行只读查询。\u003ccode class=\"literal\"\u003eminimal\u003c/code\u003e会去掉除从崩溃或者立即关机中进行恢复所需的信息之外的所有记录。最后，\u003ccode class=\"literal\"\u003elogical\u003c/code\u003e会增加支持逻辑解码所需的信息。每个层次包括所有更低层次记录的信息。这个参数只能在服务器启动时设置。\u003c/p\u003e\u003cp\u003e\u003ccode class=\"literal\"\u003eminimal\u003c/code\u003e级别生成最少的WAL日志量。对于在当前事务中创建或重写的永久关系，不记录其行信息。这可以使操作速度更快（参见\u003ca href=\"/docs/18/populate.html#POPULATE-PITR\" title=\"14.4.7. 禁用 WAL 归档和流复制\"\u003e第 14.4.7 节\u003c/a\u003e）。触发此优化的操作包括：\u003c/p\u003e\u003ctable class=\"simplelist\"\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"command\"\u003eALTER ... SET TABLESPACE\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"command\"\u003eCLUSTER\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"command\"\u003eCREATE TABLE\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"command\"\u003eREFRESH MATERIALIZED VIEW\u003c/code\u003e（不使用\u003ccode class=\"option\"\u003eCONCURRENTLY\u003c/code\u003e）\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"command\"\u003eREINDEX\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"command\"\u003eTRUNCATE\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003cp\u003e然而，minimal 级别的 WAL 不包含足够的信息用于时间点恢复，因此必须使用\u003ccode class=\"literal\"\u003ereplica\u003c/code\u003e或更高级别来启用持续归档（\u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-MODE\"\u003earchive_mode\u003c/a\u003e）和流式二进制复制。实际上，如果\u003ccode class=\"varname\"\u003emax_wal_senders\u003c/code\u003e不为零，服务器甚至不会以此模式启动。请注意，将\u003ccode class=\"varname\"\u003ewal_level\u003c/code\u003e更改为\u003ccode class=\"literal\"\u003eminimal\u003c/code\u003e会使先前的基础备份无法用于时间点恢复和备库。\u003c/p\u003e\u003cp\u003e在\u003ccode class=\"literal\"\u003elogical\u003c/code\u003e级别上，记录与\u003ccode class=\"literal\"\u003ereplica\u003c/code\u003e相同的信息，以及从WAL中提取逻辑变更集所需的信息。使用\u003ccode class=\"literal\"\u003elogical\u003c/code\u003e级别会增加 WAL 的数量，特别是如果许多表被配置为\u003ccode class=\"literal\"\u003eREPLICA IDENTITY FULL\u003c/code\u003e，并且执行了许多\u003ccode class=\"command\"\u003eUPDATE\u003c/code\u003e和\u003ccode class=\"command\"\u003eDELETE\u003c/code\u003e语句。\u003c/p\u003e\u003cp\u003e在 9.6 之前的版本中，这个参数也允许值\u003ccode class=\"literal\"\u003earchive\u003c/code\u003e和\u003ccode class=\"literal\"\u003ehot_standby\u003c/code\u003e。现在仍然接受这些值，但是它们会被映射到\u003ccode class=\"literal\"\u003ereplica\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","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}
