Middle
What are indexes in a database?
sobes.tech AI
Answer from AI
Indexes in a database are special data structures that speed up the search and retrieval of data from tables. They work like pointers to table rows, allowing quick access to the needed records without scanning the entire table.
Indexes are created on one or more columns and can be of different types: B-tree, hash indexes, etc. The main advantage is improved performance of SELECT queries.
However, indexes occupy additional space and slow down insert, update, and delete operations, as the index also needs to be updated.
An example of creating an index in SQL:
CREATE INDEX idx_customer_name ON customers (last_name);
This index will speed up searching for customers by last name.