How to debug a slow SQL query
A careful workflow from the symptom to evidence, a testable hypothesis and verification.
TuningLens knowledge base
Direct answers for developers investigating SQL plans and slow queries. Each guide states its version scope, cites primary documentation and treats every recommendation as a hypothesis to verify.
A careful workflow from the symptom to evidence, a testable hypothesis and verification.
Read access paths, indexes, row estimates, joins and Extra without overclaiming what a plan proves.
Understand that it executes the statement and plan a safer diagnostic run.
Reason about leftmost prefixes, equality, ranges, ordering and verification.
Learn when a filesort matters and how to test an ordering-index hypothesis.
Use actual execution statistics with the right safety and version caveats.
TuningLens currently analyzes MySQL and MariaDB SELECT queries only. These PostgreSQL guides are educational; PostgreSQL analysis is not available in the beta.
Understand scans, joins, estimated rows and planner costs before testing a tuning hypothesis.
Learn what it executes, what runtime measurements mean and how to investigate safely.
Check selectivity, predicates, statistics and plan evidence before changing an index.
Compare estimated and actual rows and investigate skew or correlated filters.
Understand visibility checks, heap fetches and the tradeoffs of covering indexes.
See how the process applies to an order-history query and a deep-pagination query. These examples are illustrative and make no measured speedup claims.