Diagnose SQL query performance with EXPLAIN plans

8 steps · about 2 h 10 min · Intermediate

  1. Read a PostgreSQL plan (article, Use The Index, Luke!, 18 min)

    Learn the plan vocabulary before diagnosing a slow query.

  2. Compare estimated and actual work (article, PostgreSQL documentation, 15 min)

    Spot where estimates diverge from execution.

  3. Inspect SQLite query plans (article, SQLite documentation, 15 min)

    See the same diagnostic habit in a compact database.

  4. Use plans to ask better questions (article, Use The Index, Luke!, 20 min)

    Connect plan operators to practical tuning questions.

  5. Choose an index family (article, SQLite documentation, 18 min)

    Match B-tree, hash, GiST and GIN capabilities to predicates.

  6. Limit a partial index deliberately (article, PostgreSQL documentation, 16 min)

    Learn when indexing only qualifying rows is worthwhile.

  7. Observe database activity (article, PostgreSQL documentation, 16 min)

    Use runtime statistics to avoid tuning from guesses.

  8. Refresh planner statistics (article, PostgreSQL documentation, 12 min)

    Understand why current statistics affect plan quality.