Under and Around PostgreSQL: Torn Page Protection, CREATE TEMP TABLE Cost, CNPG's 100+ Extension Catalog, Peat Fork, and Mason ReplicaThematic roundup · digest for December 3
Exploded view of the PostgreSQL core: neat 8 KB memory pages with checksum padlocks surrounded by modular extension units.
Thematic roundup5 sections≈ 6 min

Under and Around PostgreSQL: Torn Page Protection, CREATE TEMP TABLE Cost, CNPG's 100+ Extension Catalog, Peat Fork, and Mason Replica

A plain UPDATE or CREATE TEMP TABLE looks like one innocent line of SQL, yet under the hood PostgreSQL slices data into 8 KB pages, guards them through the WAL, and jostles neighbor sessions in a shared memory queue. Here are two core engine mechanics to understand, plus three open-source tools built for PG 18 and 19.

Torn page protection: how PostgreSQL survives a half-written page

PostgreSQL writes 8 KB pages while disks often flush 4 KB sectors. Lose power mid-write and you get a torn page: half new data, half old.

Two mechanisms prevent silent corruption: data_checksums (enabled by default in new clusters since PG 18) catch bad pages on reads and backups, and full_page_writes (FPI) logs the entire 8 KB page image in WAL on its first change after a checkpoint so recovery can overwrite the torn block. In Franck Pachot's experiment on PG 19, he tore a page with dd: without checksums, SELECT quietly returned a garbled mix of old rows, new rows, and 'Tha'; with checksums and full_page_writes=off, the cluster crashed with FATAL: invalid page in block 0:

-- Check page protection and FPI WAL overhead
SHOW data_checksums;
SHOW full_page_writes;
EXPLAIN (ANALYZE, BUFFERS, WAL, IO, COSTS OFF)
UPDATE corruptme SET value = 'Thanks world';

Across 50 rows, FPI bumped WAL from 4,044 to 6,673 bytes. It is only safe to turn off on copy-on-write ZFS or atomic 8/16 KB storage (like Azure Managed Disks). After upgrading from PG <18, watch pg_basebackup logs—it flags a corrupt block as WARNING first.

The hidden cost of CREATE TEMP TABLE: catalog bloat and lock contention

Coming from Oracle, reaching for CREATE TEMP TABLE in hot paths feels natural—yet in Postgres it's full DDL. Even (id int, v text) ON COMMIT DROP inserts and deletes 31 catalog rows (pg_class, pg_attribute, pg_type, pg_depend), creates 3 files (including TOAST), and broadcasts 132 messages into the shared 4,096-slot sinval queue. In PostgresAI's benchmarks on PG 18.6, pg_attribute bloated by 737–839 MiB in 70 seconds, and with 5,000 idle sessions, 500 DDL TPS collapsed to 127–249 TPS (85–91% spent in LWLock:SInvalWrite) with 731–1,065 MiB of WAL lag:

Throughput in Postgres 18.6 (32 clients)

A plain CTE is read-only, while DELETE in a reused table chokes on dead tuples without autovacuum. Temp tables also fail on read replicas and break PgBouncer transaction pooling:

-- Reusable temp table under session pooling (avoids repeated DDL)
CREATE TEMP TABLE IF NOT EXISTS t (id int, v text)
ON COMMIT DELETE ROWS;

-- Batch alternative: zero DDL, works on read replicas too
INSERT INTO dst SELECT * FROM unnest($1::int[], $2::text[]);

-- Diagnostic: take two readings 1 min apart (delta pg_attribute / 19)
SELECT relname, n_tup_del FROM pg_stat_sys_tables
WHERE relname IN ('pg_class', 'pg_attribute', 'pg_type', 'pg_depend');

When migrating a search workload from Oracle (~10M queries/day), switching to PL/pgSQL arrays and unnest() eliminated catalog pressure and unlocked read replicas. If you truly need a temp table, reuse it across the session instead of recreating it every transaction.

CNPG Extensions Catalog: 100+ CloudNativePG extensions with SBOMs

Official CloudNativePG images omit GPL extensions due to CNCF rules. CNPG Extensions Catalog (announced by Jeremy Schneider) ships 103 images for PG 18/19 (Debian trixie and bookworm) under all OSI licenses (pg-duckdb, timescaledb-oss, documentdb, pg-cron, hypopg, pg-repack) with SHA-256 digests, Renovate, and SBOMs (including pgrx Rust crates for Trivy):

# ClusterImageCatalog snippet (catalog includes @sha256 digests)
apiVersion: postgresql.cnpg.io/v1
kind: ClusterImageCatalog
metadata:
  name: postgresql-minimal-trixie
spec:
  images:
    - major: 18
      extensions:
        - name: hypopg
          image:
            reference:
              ghcr.io/cnpg-extensions/hypopg:1.4.5-202612020033-18-trixie

In the catalog manifest, watch for an upgrade gotcha: 5 extensions (timescale, postgis, pgrouting, mobilitydb, pointcloud) bake versions into .so filenames, and 33 more can drift on SQL signatures. Monitor cnpg_pg_extensions_update_available in Prometheus and run ALTER EXTENSION ... UPDATE.

Peat: a Neon Serverless Postgres fork for PostgreSQL 18 and 19

Open-source Neon stalled on PG 17.5 in July 2025. The Peat fork (release-2026-11-29.3) brings Neon's compute/storage separation to PG 18.7 and PG 19.0 (default since November 26, 2026, passing 799 regression tests). It keeps scale-to-zero, 7-day PITR, and CoW branches (<3s vs 16s for CNPG + ZFS; ~1s restore vs 20s+), plus a TypeScript/Bun Kubernetes operator (Platform, Database) storing state in K8s objects with S3 backups.

It's still Alpha (v1alpha1): Claude agents wrote most of the port with peer-agent review, and upgrading PG 18 to 19 requires pg_dump (resetting LSN history).

Mason: a columnar DuckDB analytics replica speaking the Postgres protocol

Mason (@mason-data/cli 0.23.4, Apache-2.0) is an analytical read replica inside one Node.js (>=22.13) process powered by DuckDB. It speaks the standard PostgreSQL wire protocol, parsing incoming SQL with PGlite and libpg-query before rewriting it for DuckDB while keeping Postgres types and SQLSTATEs.

Across 8,352 oracle queries, raw DuckDB matched Postgres only 23% of the time, whereas Mason hit 94% (zero silent wrong answers; 6% cleanly rejected). On 100M rows vs PG 18.7, a COUNT by status dropped from 216s to 0.462s (467–572× faster), and revenue JOINs ran 50–60× faster. Primary-key lookups are 2.7–6.2× slower, so keep OLTP on the primary:

# mason/sources/app.yml — tables and sync modes
kind: postgres
url: ${DATABASE_URL}
sync: off
tables:
  orders:
    columns: [id, customer_id, status, amount, created_at]
    sync: poll 30s
  events:
    exclude: [raw_body]
    sync: replication

It supports off, poll, and logical replication, RBAC in mason/roles.yml, and an MCP server (mason mcp) for AI agents. Note its pre-1.0 status, 3 GiB minimum RAM, and the need to set max_slot_wal_keep_size on the primary so replication slots don't fill your disk.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 12