Indexing is a way of sorting a number of records on multiple fields. Creating an index on a field in a table creates another data structure which holds the field value, and a pointer to the record it relates to. This index structure is then sorted, allowing Binary Searches to be performed on it.
How do table indexes work?
An index contains keys built from one or more columns in the table or view. These keys are stored in a structure (B-tree) that enables SQL Server to find the row or rows associated with the key values quickly and efficiently. Clustered indexes sort and store the data rows in the table or view based on their key values.
How is indexing done in database?
Recap
- Indexing adds a data structure with columns for the search conditions and a pointer.
- The pointer is the address on the memory disk of the row with the rest of the information.
- The index data structure is sorted to optimize query efficiency.