Query plan and index guides
Every guide opens with a plan or a query you can paste into the analyzer and inspect node by node.
Plan basics
Plan basicsEXPLAIN ANALYZE: what it runs, what it prints and how to read the first lineWhat EXPLAIN ANALYZE actually executesPlan basicsCost units versus milliseconds: what the planner minimises and what you measureWhy cost 18334 is not 18 secondsPlan basicsHow to read a plan tree: indentation, loops and self timeNesting, loops and the time a node ownsPlan basicsWhen the planner expects 100 rows and gets a millionEstimated versus actual rows, and what to doPlan basicsBuffers in EXPLAIN: shared hits, reads, temp blocks and what they costReading the I/O behind the time
Nodes
NodesSequential scan or index scan: the choice is about fractions, not rulesWhy a seq scan can be the fast planNodesNested loop joins: excellent for ten rows, disastrous for a millionOuter rows times inner workNodesHash joins: fast for large equality joins, until the hash table spillsBuild, probe and the batch countNodesMerge joins: when sorted inputs make the join almost freeTwo sorted streams, one passNodesWhen a sort spills to disk, and the three ways to stop itExternal merge, work_mem and avoiding the sort
Indexes and rewriting
Indexes and rewritingComposite index column order: equality first, then range, then sortEquality first, range next, sort lastIndexes and rewritingPartial and covering indexes: smaller indexes that answer moreIndex only the rows and columns you needIndexes and rewritingSargable predicates: why an index is ignored and how to rewrite the filterTurn a filter into something an index can seekIndexes and rewritingMySQL EXPLAIN ANALYZE: the tree format and what is different from PostgreSQLReading MySQL's executed plan treeIndexes and rewritingWhy format SQL, and what a linter can and cannot catchReadable SQL and the rules that prevent incidents
Every guide links to the analyzer, so the plan discussed in the article can be pasted in and inspected node by node.
Open the analyzer