Solve “Deduplicate events with ROW_NUMBER”

Free. Runs in your browser, no install.

SQL · Query Optimization

What is an index?

Hardindexperformance

Interview question

What is an index?

How to answer

The short answer

An index is a data structure that helps the database find rows faster without scanning the entire table.

Imagine:

Instead of reading every page, you look in the index.

Example:

SQL
CREATE INDEX idx_customer_email
ON customers(email);

Now searches on email may be faster.

Downsides

  • Extra storage
  • Slower INSERT/UPDATE/DELETE
  • Maintenance overhead
  • Too many indexes can hurt write performance

Lock it in with a real drill

You remember an answer longer once you have used it. Try a hands-on problem on this concept.

Open related drill