Skip to content

append_only_heap

PostgreSQL table access method that avoids fragmentation of variable-length append-only data.

append_only_heap · PostgreSQL table access method that avoids fragmentation of variable-length append-only data.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100517append_only_heapappend_only_heap1.0FEATMITC

Usage

Sources:

append_only_heap is a table access method that reuses PostgreSQL heap behavior but adds HEAP_INSERT_SKIP_FSM to inserts. New tuples therefore avoid free-space-map holes, which can reduce fragmentation for variable-length workloads that truly append data.

Create a Trial Table

CREATE EXTENSION append_only_heap;
CREATE TABLE event_log (
  event_id bigint GENERATED ALWAYS AS IDENTITY,
  payload jsonb NOT NULL
) USING append_only_heap;

INSERT INTO event_log(payload) VALUES ('{"event":"created"}');
SELECT * FROM event_log;

Caveats

  • The name does not enforce immutability: UPDATE, DELETE, and TRUNCATE remain inherited heap operations. Enforce an append-only policy separately.
  • The version 1.0 implementation calls mprotect and overwrites function pointers in PostgreSQL’s otherwise constant process-global TableAmRoutine. That unsupported internal hook can fail to load, conflict with other modules, or break after a server change.
  • Skipping free-space reuse increases relation growth when rows are updated or deleted. Treat this as experimental storage code, benchmark bloat and vacuum behavior, and test crash recovery and upgrades on disposable data.

Table reader