# wal_keep_size

> WAL held back in pg_wal so a streaming standby that reconnects can catch up.

Source: https://sqlly.app/sql-configuration/postgresql/wal-keep-size
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).

**Default**

`0`

**Range**

0 to about 2PB, in MB

**Restart needed**

No

**Default checked on**

PostgreSQL 18

## What it does

The minimum size of past WAL segments reserved for standby servers. A standby that disconnects briefly re-reads what it missed; segments already recycled force a fresh base backup. Renamed from wal_keep_segments in PostgreSQL 13, which counted 16MB segments rather than megabytes.

## Default value

`0`. 0 (PostgreSQL 18); exists as wal_keep_size since PostgreSQL 13 (wal_keep_segments before).

## Check the current value

```
SHOW wal_keep_size;

SELECT setting, unit, boot_val, context, source, pending_restart
FROM pg_settings
WHERE name = 'wal_keep_size';
```

## Change it

```
ALTER SYSTEM SET wal_keep_size = '1GB';
SELECT pg_reload_conf();
```

No restart: reload with SELECT pg_reload_conf() or pg_ctl reload. It cannot be changed per session (context is sighup).

## When to change it

On primaries with physical standbys that do not use replication slots, or as extra margin next to a slot sized by max_slot_wal_keep_size.

## What can go wrong

The space is held in pg_wal even when no standby is connected, so a value far above what the standbys need is wasted disk. A standby that falls further behind than this plus any slot allowance cannot rejoin without a base backup.

## Questions about wal_keep_size

### What is the default value of wal_keep_size in PostgreSQL?

0. 0 (PostgreSQL 18); exists as wal_keep_size since PostgreSQL 13 (wal_keep_segments before).

### Does changing wal_keep_size require a restart?

No. No restart: reload with SELECT pg_reload_conf() or pg_ctl reload. It cannot be changed per session (context is sighup).

### When should I change wal_keep_size?

On primaries with physical standbys that do not use replication slots, or as extra margin next to a slot sized by max_slot_wal_keep_size.

Back to all [PostgreSQL settings](https://sqlly.app/sql-configuration/postgresql), or check the [PostgreSQL manual](https://www.postgresql.org/docs/current/runtime-config.html) for every option.

## Related PostgreSQL settings

- [`max_slot_wal_keep_size` Most WAL a replication slot may hold back before it is invalidated; -1 is unlimited.](https://sqlly.app/sql-configuration/postgresql/max-slot-wal-keep-size)
- [`wal_level` How much information is written to the WAL.](https://sqlly.app/sql-configuration/postgresql/wal-level)
- [`max_wal_size` WAL volume that triggers a checkpoint before checkpoint_timeout is reached.](https://sqlly.app/sql-configuration/postgresql/max-wal-size)
