A database index is a data structure that speeds up lookups by allowing a database to find rows without scanning an entire table. Indexes work similarly to the index in a book, pointing to locations where specific values appear. They are commonly implemented using B-trees or hash tables. Indexes improve query performance but require extra storage and increase write costs because they must be updated when data changes.
Why it matters
Without indexes, even simple queries on large tables would be slow and resource-intensive. Proper indexing is essential for scalable applications and efficient database operations. Understanding indexes helps developers interpret query plans and optimize performance.
Examples
Adding an index on an email column speeds up user lookups. Lessons like Indexes Explained show how indexing affects performance.