How to Create an Index in MySQL
Last updated July 25, 2026 · By the SaturnSQL team
Use CREATE INDEX name ON table (columns), or ALTER TABLE ... ADD INDEX. In composite indexes column order matters: put equality-filtered columns before range-filtered ones. Verify the index is actually used with EXPLAIN.
CREATE INDEX idx_orders_status ON orders (status);Composite index
CREATE INDEX idx_orders_customer_created
ON orders (customer_id, created_at);Check it is used
EXPLAIN SELECT * FROM orders
WHERE customer_id = 101 AND created_at >= '2026-01-01';Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free