All games

SQL Index Quest

Choose the best database index for simplified schemas and queries while learning full scans, covering indexes, sort avoidance, and composite order.

Concept
Database indexing and query performance
Difficulty
Intermediate
Play time
7-10 minutes
Path
Data & Performance
practice/sql-index-quest Index planning score

Play, get feedback, save local progress, and optionally submit a leaderboard score.

Concept explanation

SQL indexes are one of the highest-leverage backend performance tools. This game simplifies query planning so you can practice the judgment behind index selection.

Your local progress

0 XP 0 games played 0 completed

Progress, review history, and best scores are stored in this browser with localStorage.

Open full progress dashboard

Playable game area

Use the controls below. Feedback appears immediately, and final scores are stored locally.

Leaderboard

Top 10 submitted scores. No account required.

Loading leaderboard...

    Finish the game to load your latest local score.

    Learning objectives

    • Choose indexes that match filters and ordering.
    • Apply the leftmost prefix rule for composite indexes.
    • Recognize when an index is low-value or creates unnecessary write overhead.

    How to play

    1. Inspect the schema, row count, and query.
    2. Pick the index that best supports filtering, sorting, and selected columns.
    3. Read the simplified query-plan feedback.

    Scoring

    • Best index choices earn full points.
    • Partially helpful indexes explain what they improve and what they miss.
    • Poor indexes lose points because they add write overhead without helping the query.

    Backend concept notes

    Indexes speed reads by keeping ordered lookup structures, but every index costs storage and write work. Backend engineers choose indexes for real query patterns, not for every column.

    Composite index order matters. An index on (user_id, created_at) helps queries that start with user_id, but it does not act like a standalone created_at index for every query.

    Common mistakes

    • Indexing a low-cardinality boolean column by itself and expecting a large speedup.
    • Creating composite indexes in the wrong column order.
    • Ignoring ORDER BY and then paying for a separate sort.

    FAQ

    Short answers for how this game fits backend interview and study practice.

    Does every foreign key need an index?

    Many do, especially when joined or filtered often, but the final choice should come from query patterns and write costs.

    What is a covering index?

    A covering index includes all columns needed by a query, allowing the database to answer from the index without reading the table row.