Indexes and Clustering
Understand how DB2 indexes accelerate access, why clustering indexes matter for physical row order, and the tradeoffs of adding indexes.
Indexes are the primary lever DB2 developers pull to influence query performance, and understanding both how they accelerate lookups and what they cost in return is essential for any performance-oriented interview discussion. An index is a separate physical structure (a B-tree) mapping key column values to the physical location of matching rows, letting DB2 avoid scanning an entire table space to find matching rows.
A non-clustering index is the index at the back of a textbook pointing you to scattered page numbers for a topic; a clustering index is more like actually reorganizing the whole book so all the pages about that topic sit physically next to each other — faster to read through in bulk, but every time you insert a new page you have to carefully re-sort the whole section rather than just adding one line to the back index.