Easy Writes & indexes Free

SQL interview question: Create an Index

Speed Up Customer Lookups

The dashboard's most frequent query is "orders for customer X", and it's doing a full table scan every time.

Create an index named exactly idx_orders_customer on the customer_id column of orders.

Note: Your index is verified automatically (including which column it covers) and rolled back afterwards.

This challenge changes data. Your statement runs on a private copy of the database, then we check the resulting table.

Tables

orders 15 rows
  • order_id integer PK
  • customer_id integer → customers
  • order_date text
  • total_amount real
  • status text
order_idcustomer_idorder_datetotal_amountstatus
11012024-01-20249.99delivered
21012024-03-151999.99delivered
41012024-09-0579.99delivered

Keep going