How would you optimise a slow query?

SQL indexes, transactions and performance · Experienced

Model answer

Reproduce it, read the EXPLAIN plan, and find the costliest step. Typical fixes: add or adjust an index, select fewer columns and rows, rewrite subqueries or joins, avoid functions on indexed columns, update statistics, paginate with keysets, and cache or precompute heavy results. Measure after each change.

Learn this topic

Indexes and Faster Queries: EXPLAIN for Beginners in the course SQL for Beginners: Learn Databases Step by Step.

Sign in to add your own answer.

More questions