Learn Everything

Paths/Backend Engineer/Relational Databases / Schemas & Indexes

Practice Taskintermediateubuntu:24.04Ask AI

Index the Queries You Run

An index is a bet on the queries you actually run. Write the composite indexes for the two hot paths of the orders table.

Validator

⏱ 0:00

IDLE — checks run live as you type commands; submit when done

01Requirements

live checks
  • File ~/backend/db/indexes.sql exists○
  • The file creates a composite index over the status and the created_at column○
  • The file creates an index on the foreign key○

02Walkthrough

1 of 4 revealed
  1. 01

    Write the first index

    The order of the columns matters - equality first, range last. status is filtered on exactly, created_at is sorted on.

    echo CREATE INDEX idx_orders_status_created_at ON orders (status, created_at DESC); > ~/backend/db/indexes.sql
  2. 3 locked · each failed submit reveals one

03Stuck?

0 of 3 revealed

Take a hint without losing the lab — each one points at the thing to look at, not at the answer.

04AI Tutor

guides, never solves

Tell me what you're stuck on — I'll nudge, not solve. Which requirement are you looking at?

04Notebook

saved locally in this browser

learner@lab — ubuntu:24.04

↑/↓ recalls commands · Ctrl+Enter submits · type help for the command list