Skip to content
Justice Tech School

Indexes

An index is a lookup structure on one or more columns, like the index of a book. It makes WHERE, JOIN and ORDER BY on those columns much faster, but it uses space and slows down inserts a little. Index the columns you search and join on, not every column.

Example
CREATE INDEX idx_students_country ON students (country);
SELECT name FROM students WHERE country = 'Kenya';

Result

name
Wanjiru
Example
DROP INDEX idx_students_country;

Exercise

Create an index.

 INDEX idx_name ON students (name);

Quiz Test

What is the trade off of an index?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.