NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Middle87 views

Что вы анализируете в EXPLAIN ANALYZE и какие проблемы находили на практике, помимо добавления индексов?

Practice

AI answer

In EXPLAIN ANALYZE (in PostgreSQL), I compare the planner’s estimates with the actual row counts and execution times for each node: large discrepancies point to cardinality estimation errors. I examine the join types and order, loops, filtered rows, buffers and reads, parallel nodes, as well as sorts and hash operations that may have spilled to disk. I keep in mind that EXPLAIN ANALYZE actually runs the query and adds overhead of its own.

Besides missing indexes, common issues include stale statistics, a poor query shape or unnecessary joins, filtering after reading a large volume of data, functions or type casts that prevent index use, lack of partition pruning, sorts spilling to disk, and selecting too many columns. I also check for N+1 queries at the application level and the impact of competing workloads. Then I change one cause at a time and compare the plan and execution time on representative data.