Solve “Deduplicate events with ROW_NUMBER”

Free. Runs in your browser, no install.

SQL · Query Optimization

What is a covering index?

Hardcovering indexindexperformance

Interview question

What is a covering index?

How to answer

The short answer

A covering index holds every column the query needs, so the engine can often answer from the index alone without fetching the table row.

Example:

SQL
CREATE INDEX idx_customer
ON customers(email, name);

Query:

SQL
SELECT name
FROM customers
WHERE email = '[email protected]';

The index contains both:

Output
email
name

so a separate table lookup may not be required.

In short

> Regular index → find the row, then visit the table. > Covering index → everything needed is already in the index.

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