pg_column_tetris

Enforce optimal column alignment to minimize row padding

Overview

PackageVersionCategoryLicenseLanguage
pg_column_tetris0.1.0ADMINMITSQL
IDExtensionBinLibLoadCreateTrustRelocSchema
5280pg_column_tetrisNoNoNoYesNoNocolumn_tetris
Relatedplpgsql pg_repack pgstattuple pg_squeeze pg_rewrite pg_dirtyread

Upstream has no release or tag; source archive is normalized from commit e70f9867c63e932cdaf87b2d34b6504adad9ce12.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.1.01817161514pg_column_tetrisplpgsql
RPMPIGSTY0.1.01817161514pg_column_tetris_$v-
DEBPIGSTY0.1.01817161514postgresql-$v-pg-column-tetris-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
el8.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
el9.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
el9.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
el10.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
el10.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
d12.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
d12.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
d13.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
d13.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
u22.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
u22.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
u24.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
u24.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
u26.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
u26.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0

Build

You can build the RPM / DEB packages for pg_column_tetris using pig build:

pig build pkg pg_column_tetris         # build RPM / DEB packages

Install

You can install pg_column_tetris directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pg_column_tetris;          # Install for current active PG version
pig ext install -y pg_column_tetris -v 18  # PG 18
pig ext install -y pg_column_tetris -v 17  # PG 17
pig ext install -y pg_column_tetris -v 16  # PG 16
pig ext install -y pg_column_tetris -v 15  # PG 15
pig ext install -y pg_column_tetris -v 14  # PG 14
dnf install -y pg_column_tetris_18       # PG 18
dnf install -y pg_column_tetris_17       # PG 17
dnf install -y pg_column_tetris_16       # PG 16
dnf install -y pg_column_tetris_15       # PG 15
dnf install -y pg_column_tetris_14       # PG 14
apt install -y postgresql-18-pg-column-tetris   # PG 18
apt install -y postgresql-17-pg-column-tetris   # PG 17
apt install -y postgresql-16-pg-column-tetris   # PG 16
apt install -y postgresql-15-pg-column-tetris   # PG 15
apt install -y postgresql-14-pg-column-tetris   # PG 14

Create Extension:

CREATE EXTENSION pg_column_tetris CASCADE;  -- requires: plpgsql

Usage

Sources:

pg_column_tetris 0.1.0 is a pure-SQL extension for PostgreSQL 14 through 18. An event trigger estimates alignment padding after CREATE TABLE and can warn about or reject inefficient column order. It also provides inspection and rewrite-suggestion functions.

Inspect and choose enforcement

The default mode is warn; strict rejects a newly created table that the estimator considers suboptimal, and off disables the event-trigger check.

CREATE EXTENSION pg_column_tetris;

SELECT column_tetris.mode();
SELECT * FROM column_tetris.check('public.measurement'::regclass);
SELECT column_tetris.padding_wasted('public.measurement'::regclass);

SELECT column_tetris.set_mode('warn');

Use column_tetris.exclude() for tables that must not be checked. Temporary and system tables are skipped, and the event trigger checks table creation rather than every later alteration.

Treat estimates and rewrites as advisory

The estimator models tuple headers and type alignment, but it cannot fully predict real storage for null bitmaps, variable-length or toasted values, compression, and workload-specific row populations. A reported byte saving is therefore a design signal, not measured disk reclamation.

column_tetris.suggest_rewrite() returns a migration script; it does not preserve every foreign key, index, trigger, or default. The generated sequence renames the original table, creates and copies a replacement, and drops the old table, which can require an exclusive lock and downtime. Never execute that output without reviewing dependent objects, privileges, identity and sequence behavior, replication, rollback, and a realistic staging rehearsal. Column order can also be part of application contracts such as positional inserts and row decoding.


Last Modified 2026-07-30: extension update 2026-07-30 (7219c44)