sqlANYpostgresqlexplainanalyze
sql
EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM users WHERE email = 'a@example.com';This is often the first stop for PostgreSQL tuning.
Use EXPLAIN tools across PostgreSQL, MySQL, SQLite, and MongoDB to prove whether an index actually helps.
Different engines use different plan inspection commands.
EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM users WHERE email = 'a@example.com';This is often the first stop for PostgreSQL tuning.
EXPLAIN SELECT * FROM users WHERE email = 'a@example.com';Check the selected key, rows estimate, and extras such as filesort or temporary operations.
EXPLAIN QUERY PLAN SELECT * FROM users WHERE email = 'a@example.com';Very useful in mobile, local, and embedded app debugging.
db.users.find({ email: 'a@example.com' }).explain('executionStats')A large drop in docs examined is a strong sign the index is paying off.
General signals that the index is helping.
Look for:
- indexed search instead of full scan
- fewer rows/docs examined
- fewer extra sorts
- lower latency under realistic load
- acceptable write overheadDo not stop at 'the index exists'. Confirm that it materially improves the real workload.