Describe what an index does to a database query.
An index changes how a database query accesses data: instead of scanning an entire table, the database can use the index to find matching rows much faster. More specifically, an index is a separate data structure—commonly a B-tree, hash, or bitmap—that stores a sorted copy of one or more columns along with pointers back to the actual table rows. When you run a query, the database optimizer may choose to use an index for operations such as: - `WHERE` filters - `JOIN` conditions - `ORDER BY` sorting - `GROUP BY` aggregation - `DISTINCT` or uniqueness checks For example: ```sql SELECT * FROM employees WHERE last_name = 'Smith'; ``` Without an index on `last_name`, the database may perform a full table scan, reading every row to find matches. With an index on `last_name`, it can traverse the index structure to jump directly to the matching entries, reducing I/O and improving response time. In short, an index speeds up read queries by replacing full scans with efficient lookups, at the cost of slower writes and extra storage, because the index must be maintained whenever data is inserted, updated, or deleted.