Dataindex-organised tableindex-organized tableheap table

Clustered index

Definition

In a clustered index the leaves of the primary key B-tree are the rows; secondary indexes then store the primary key as their pointer instead of a physical row location.

In practice

MySQL InnoDB and SQL Server cluster tables by primary key, so range scans and lookups by that key read rows directly without a second hop. PostgreSQL does not: every index, including the primary key, points into a separate heap by physical row location, and CLUSTER only reorders the heap once.

Because every secondary index lookup goes through the primary key, a wide primary key makes every index bigger. Random primary keys such as UUIDv4 scatter inserts across the whole table, causing page splits and half-empty pages; time-ordered keys like UUIDv7 or sequences keep inserts at the end.

Example

In InnoDB, looking up users by email searches the email index, finds primary key 81723, then descends the clustered index to read the row.