@sargonpiraev

Indexes

Created 1 min readseed · 1/5#database

An index is a secondary structure maintained alongside the main data so the engine can answer lookups and range queries faster, at the cost of extra storage and slower writes.

Different index families match different shapes of data and query: B-tree for ordered keys and ranges, hash for equality-only lookups, inverted structures for text and arrays, lightweight block-range indexes for append-heavy ordered tables, and more.

Composite indexes care about column order: a multi-column index may help queries that prefix the first columns more than queries that only use later columns.

Always validate plans against real data: bad statistics often matter more than “more indexes.”

For PostgreSQL index types and operational notes, see Postgres indexes.