- An index orders data for fast retrieval
- Indexes can be used for querying or sorting
- Indexes also use memory
ComponentVersion
ID | Component | Component Version | Release Date |
1 | Base | 1.0 | 2006-01-07 |
3 | Base | 1.1 | NULL |
Searching for all releases in Q1 does not use an index:
EXPLAIN SELECT * FROM component_version
WHERE release_date BETWEEN '2006-01-01' AND '2006-03-31';
Create an index with:
ALTER TABLE component_version
ADD INDEX component_version_release_date (release_date);