What is an index in MySQL?

An index helps MySQL find rows quickly, without reading every row of the table, like the index of a book helps you find a page.

CREATE INDEX idx_city ON students (city);

EXPLAIN SELECT * FROM students WHERE city = 'Delhi';
  • Use indexes on columns used in WHERE, JOIN and ORDER BY.
  • Indexes use space and make INSERT, UPDATE and DELETE a little slower, so do not index everything.

See MySQL Indexes.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.