Query processing

Pathkeys

Also called: sort order, path ordering

Pathkeys are how the planner records the sort order a path produces its rows in. An index scan on (created_at) has pathkeys saying "already ordered by created_at"; a sequential scan has none.

What this means

How the planner keeps track of the order a set of rows already comes in. An index scan on (created_at) carries pathkeys saying "these arrive sorted by created_at"; a plain sequential scan carries none. That bookkeeping is how the planner knows it can skip a later sort step.

Why it matters operationally

Order is valuable. If a path already delivers rows in the order an ORDER BY, merge join, or GROUP BY needs, the planner can skip a sort entirely. That is why pathkeys are one of the dimensions on which a path can survive even when its total cost is higher, the free ordering pays for itself downstream.

← All glossary terms · GUC reference · Error catalog