Glossary — in plain language

Column alignment (padding)

Also called: attalign, alignment padding, column tetris

In plain English

Each PostgreSQL data type has an alignment requirement (attalign in pg_attribute): 8-byte, 4-byte, 2-byte, or 1-byte. When a row is laid out, each column’s start is rounded up to its alignment boundary, and the gap bytes inserted to get there are padding. An int4 followed by an int8, for example, leaves a 4-byte hole.

Why it matters

Padding is pure overhead, and how much you get depends on the order of columns. Arranging columns from widest alignment to narrowest (8-byte first, variable-length last) squeezes the holes out, shrinking every row — the optimisation nicknamed “column tetris”. On a large table that is meaningful disk and I/O savings for free.

Was this helpful?

← Browse the full glossary