Storage & tuples

Tuple deforming

Also called: heap_deform_tuple, tuple unpacking, column extraction

Deforming is the process of turning a packed on-disk row (a byte string with a header, optional NULL bitmap, and padded column values) back into usable column values. PostgreSQL walks the tuple left to right in heap_deform_tuple(), applying each type's alignment, and fills two arrays: values[] (the Datums) and isnull[].

What this means

On disk a row is just a packed string of bytes, a header, a NULL map, and column values squeezed together with padding. Deforming is unpacking that back into real column values, walking the row left to right and honoring each type's alignment as it goes. Every column you read pays a little of this cost.

Why it matters operationally

Almost every row PostgreSQL processes is deformed, so it is a genuine hot path. The executor deforms lazily, only up to the highest column a query references, which is why selecting a late column (after a variable-length or NULL column) costs more than selecting an early one.

← All glossary terms · GUC reference · Error catalog