IT lexicon › Database › Composite index

Composite index Multicolumn index

Database På svenska → Updated: 2026-07-29

An index over several columns in a specific order. The key is sorted first by one column, then by the next — exactly like a phone book sorted by surname and then first name.

Hence the most important rule: the leftmost prefix applies. An index on (customer_id, date) helps queries on customer_id alone and on both together, but not a query filtering only on date. The order is therefore a design decision, not a detail. Rules of thumb: equality predicates first, ranges and sorting last, and put the most selective column early when the choice is free. A well-planned composite index often replaces three single-column indexes and additionally enables index-only scans. Some databases can skip an unused leading column with a skip scan, but don't rely on it.

← Back to the lexicon