Middle+
Why is an index needed in a database?
sobes.tech AI
Answer from AI
An index in a database is used to speed up search and data retrieval. It works like a pointer or a table of contents in a book — allowing you to quickly find the needed information without scanning all records.
Without an index, a query to a DBMS table must scan all rows (full scan), which takes a lot of time on large datasets. Indexes are created on one or more columns and allow for quick record retrieval based on the values of these columns.
Example: if you have a user table with millions of records, an index on the email field will allow you to quickly find a user by email without scanning the entire table.