What a plan tells you
In SQLite, EXPLAIN QUERY PLAN includes operations such as SCAN and SEARCH, and can show which index is used. A SCAN is not automatically bad: it can be best for a small table or a query that needs most rows. PostgreSQL's EXPLAIN shows estimated costs and row counts; EXPLAIN ANALYZE runs the query and adds actual measurements.
A useful investigation
Start with the exact slow query and representative data. Check whether the plan reads far more rows than expected, repeats an expensive operation, sorts a large result, or fails to use an index that should help. Compare estimated and actual row counts where the engine exposes both. A large difference can mislead later planner choices.
Then change one thing—an index, predicate, or query shape—and compare plans and timing again. Keep in mind that timings vary with cache state and workload. Do not add an index just because one plan says SCAN; table size, selectivity, and write cost matter.
For example, an index on orders(customer_id) may help a selective lookup but not a query that returns nearly every order. See indexes and composite indexes.
Explain is engine-specific
Plan output is not a stable cross-database format. SQLite's query-plan output is a high-level description, not an actual row-by-row execution profile. PostgreSQL's EXPLAIN ANALYZE executes the statement, so use care with statements that modify data. Consult the target engine and version.
Compare plans with a controlled test
Use the same database state and query parameters when comparing plans. Record the selected index, actual row counts and timing where available, then vary one factor. A plan for a tiny development table may differ from production because statistics and selectivity differ. For PostgreSQL, EXPLAIN ANALYZE executes the statement, so wrap a data-changing experiment in a transaction and roll it back if appropriate. For SQLite, use EXPLAIN QUERY PLAN to inspect strategy, then measure execution separately; it does not report actual per-step timing.