What is a database index, in simple terms?
Options
- A backup copy of the table that is kept in the same database
- A lookup structure that finds rows without reading the whole table (Correct option)
- The row number of each record in the table, starting from one
- A list of the users who have access to the database tables
Answer
A lookup structure, like a book's index, that lets the database find rows without reading the whole table
Why
Without an index, finding email = 'ana@x.com' means checking every row, one by one (a full scan).
An index keeps the values sorted with pointers to the rows, so the database can jump straight to the right place, like using the index at the back of a book instead of reading every page.
Primary keys and UNIQUE columns get an index automatically.
Remember
Index = fast lookup, like a book's index.