Memory

Per-tuple memory context

Also called: per-tuple context, ecxt_per_tuple_memory, short-lived expression context

The per-tuple memory context is a tiny arena the executor uses for evaluating expressions on a single row (ExprContext.ecxt_per_tuple_memory). It is reset between every row, so scratch memory from one tuple is thrown away before the next is processed.

What this means

A throwaway scratch arena the executor uses while evaluating expressions on a single row. It's wiped clean between every row, so the leftover scratch from one tuple never piles up as the query grinds through millions of them.

Why it matters operationally

This is why a function evaluated across 100 million rows doesn't accumulate 100 million allocations, and why C functions can palloc freely without freeing. The reset between rows is the cleanup. Allocating in a longer-lived context inside a per-row loop, by contrast, is a real leak.

← All glossary terms · GUC reference · Error catalog