Index
A structure that lets a database find rows by value without reading the whole table.
Also written indexes, composite index
An index on a table column works like the index of a book: rather than reading every page to find a topic, you look it up and go straight there.
Without one, finding the rows matching a condition means scanning every row in the table. On a table of two billion rows that is ruinous. With a suitable index, the same query touches a handful of pages.
Indexes are built on one column or several together, and a composite index only helps queries that use its leading columns, a detail that explains a great many mysteriously slow queries.
They are not free. Every insert, update and delete must maintain every index on the table, so more indexes make reads faster and writes slower. Deciding the balance is a database administration judgement, made against how the tables are actually used.
For an application programmer the practical point is to know which indexes exist on the tables you query, and to write conditions that let them be used. A function applied to an indexed column will often prevent the index being used at all.
Related terms
- DB2 for z/OSIBM's relational database on the mainframe, where a great deal of the world's banking and insurance data is stored.
- SQLThe language used to query and change relational data. The same SQL used everywhere else, running against mainframe tables.
- Primary keyThe column or columns that uniquely identify each row in a table, so no two rows share the same value.
- BINDPreparing a program's SQL for execution, working out how each statement will access the data and storing the result.
- KSDSThe most common VSAM dataset type, where every record has a unique key used to find it directly.