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,JOINandORDER BY. - Indexes use space and make
INSERT,UPDATEandDELETEa little slower, so do not index everything.
See MySQL Indexes.
Learn more about the similar topics:
| Tutorials |
|---|
| MySQL Indexes |
| MySQL Views |
| MySQL Transactions |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| What is an index in MySQL? |
| What is a view in MySQL? |
| What is a transaction in MySQL? Explain ACID |
| What is a stored procedure in MySQL? |
| What is a trigger in MySQL? |