Covering Indexes
A covering index includes all columns needed by a query, so MySQL can answer it entirely from the index without touching the table data.
A covering index includes all columns needed by a query, so MySQL can answer it entirely from the index without touching the table data.
-- Query needs status, customer_id, total
-- Create a covering index with all three columns
CREATE INDEX idx_cover ON orders (status, customer_id, total);
-- EXPLAIN shows "Using index" — no table access
SELECT status, customer_id, total
FROM orders
WHERE status = 'shipped' AND customer_id = 10;
Look for "Using index" in EXPLAIN Extra — that means a covering index hit.