What is log compaction?

Definition

Log compaction prevents an ordered change log from growing without bound. A system can create checkpoints, combine operations or retain only the latest relevant record for each key, depending on its recovery model.

Compaction must preserve a validated recovery point before old records are discarded. Incorrect or interrupted compaction can make state unrecoverable, so systems commonly build and verify a new generation before promoting it.

Acronyms and aliases

WAL compaction acronym

Frequently asked questions

Why compact a write-ahead log?

Compaction reduces storage and replay time while retaining the information required to reconstruct current state.

Is log compaction the same as deleting old records?

It can remove superseded records only after a verified compacted representation or checkpoint safely preserves required state.

Videos explaining log compaction