CodeBlanks Logo Icon CodeBlanks

What is an INDEX?

Learn that an index speeds up search.

What is an INDEX?

An INDEX speeds up searches. It acts like a table of contents in a book.

CREATE INDEX idx_name ON customers (name);

This query creates an index on the name column.

The index idx_name is created.

What is an INDEX? — details

An INDEX speeds up queries but slows down writes. Each INSERT/UPDATE also updates the index.

For example, on a site where users log in by email, indexing the email column makes a lookup among millions of rows almost instant.

Practice What is an INDEX?

Add an idx_name index on the name column of customers.

Starter code

query.sql
-- create index
CREATE INDEX

Sample solution

query.sql
CREATE INDEX idx_name ON customers (name);

Expected output

İndeks oluşturuldu

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What does an INDEX speed up?

  • Creating tables
  • Writes
  • Deletes
  • Searches Correct answer

Explanation: An INDEX speeds up searches.

2 Add CREATE INDEX

Question
CREATE ____ idx_name ON customers (name);
Answer
CREATE INDEX idx_name ON customers (name);

Explanation: CREATE INDEX builds an index on a column and speeds up searches.

3 What is an INDEX: match the terms

Term Meaning
INDEX speeds up
CREATE create
ON on
write slows

All lessons in Intermediate