Performance for SQLs
SQL performance is about making queries return quickly as data grows. Indexes, most often B-tree, let the engine find rows without scanning the whole table, and the query plan from EXPLAIN shows how it will execute. Reading plans reveals missing indexes, poor join orders and costly sorts, so tuning is based on evidence.
Stage: Performance and Practice · Part of the SQL roadmap · Last reviewed 19 November 2026
What to learn in Performance
- Create a single-column and a composite index for a given query
- Read an EXPLAIN plan and tell a sequential scan from an index scan
- Order the columns of a composite index to match the query filters
- Spot queries that cannot use an index, such as a function on the column
- Weigh the write cost and storage cost of adding indexes
Performance interview questions
Why might a query not use an existing index?
Common reasons are applying a function to the indexed column, a leading wildcard in LIKE, a type mismatch, low selectivity where scanning is cheaper, or stale statistics. The planner chooses the cheapest plan it estimates, so check EXPLAIN rather than assuming.
How does column order in a composite index matter?
An index on (a, b) is sorted by a then b, so it serves filters on a, or on a and b, but not b alone. Put equality-filtered and more selective columns first, and align trailing columns with sorting needs.
Where Performance fits in the SQL roadmap
Performance belongs to the Performance and Practice stage (intermediate level), which takes about 18 hours. Make it fast and correct.