Code Quiz

Composite Index Column Order Mistake

Spot why a composite index fails to speed up a query that filters on the wrong column.

Codesql
-- Table: orders(id, customer_id, status, created_at)

CREATE INDEX idx_orders_status_customer
  ON orders (status, customer_id);

-- Frequent query the index is meant to accelerate:
SELECT id, status
FROM orders
WHERE customer_id = 42;

Why does the index fail to speed up the query?