You cannot safely refactor a query whose access path you have not characterized. In a messy repository, the useful unit of change is one query with a pinned plan and a pinned result set. Capture both before editing; then make the smallest change that keeps both explainable.
EXPLAIN QUERY PLAN is a SQLite feature. The official documentation describes its output in terms of SCAN and SEARCH records for table access and USE TEMP B-TREE records when SQLite needs a temporary B-tree for ORDER BY, GROUP BY, or DISTINCT: https://www.sqlite.org/eqp.html . That makes the plan a useful performance-contract snapshot. It is not a correctness oracle; a plan can stay identical while rows change, so keep a row snapshot too.
Who this is for
You are touching a query layer assembled from strings, helpers, or an ORM escape hatch. Rows come back, tests are green, and you do not know whether your rewrite just turned an index seek into a full scan.
Row-level golden tests will not show you the plan.β¦