Search index
- SQL course
- Intermediate
- Lesson 87/115
- 5 min
Speed up search with CREATE INDEX.
Search index
To speed up title search you add an index on the title column.
CREATE INDEX idx_title ON posts (title);This query speeds up title searches.
The index idx_title is created.
Search index — details
An index speeds up search queries. It goes on frequently searched columns.
For example, WHERE title LIKE 'SQL%' benefits from an index on title, but searches starting with a wildcard such as '%SQL%' can't use it.
Practice Search index
Add an idx_title index on title of posts.
Starter code
-- title index
CREATE INDEXSample solution
CREATE INDEX idx_title ON posts (title);Expected output
İndeks oluşturuldu
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Add CREATE INDEX
CREATE ____ idx_title ON posts (title);
CREATE INDEX idx_title ON posts (title);
Explanation: An index on title speeds up searches by title.
2 What does an index speed up?
- Creating tables
- Searches Correct answer
- Deletes
- Backup
Explanation: An index speeds up searches.
3 Search index: match the terms
| Term | Meaning |
|---|---|
CREATE INDEX |
create |
title |
title |
search |
fast |
frequent |
index |