Junior From PDF SQL SQL & Databases

What is an index in SQL and how does it work?

Short answer: An index in SQL is a database object that improves the speed of data retrieval operations on a table.

Explain a bit more

It works by maintaining a sorted order of column values in a separate structure, allowing for faster search and retrieval compared to scanning every row in the table. The index essentially creates a quick lookup table to find specific values. Example of an index creation: CREATE INDEX idx_column_name ON table_name(column_name); Indexes are particularly useful for queries that involve WHERE, JOIN, ORDER BY, and GROUP BY clauses.

Real-world example (ShopNest)

ShopNest adds an index on Orders(CustomerId, CreatedAt) because “my recent orders” is queried constantly.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details