2024-12-18 · Lin Okada
Three questions we ask before recommending an index
First: what is the selectivity and cardinality of the predicate? Ultra-low selectivity sometimes wants a different access path entirely. Second: what writes will pay rent on this index? Heavy insert streams may prefer partial indexes with honest predicates. Third: can a covering index remove a sort or join hop without duplicating half the table?
If the answer to the third is “only with twelve included columns,” we push back. In reviews, we ask for a before/after plan snippet and a note on expected table growth. That discipline prevents index gardens that confuse future you.
Students in the workshop keep a personal “index diary” for two weeks on any non-toy repo they can share. Patterns emerge quickly: most regrettable indexes were created to silence a slow log entry without a hypothesis.
Tags: indexing, performance, sql