This talk will cover the process of debugging a bad PostgreSQL plan starting from the EXPLAIN output through hacking in a fix and recompiling the database. It’s meant as a jumpstart for those who are interested in contributing to Postgres planner but aren’t quite sure how to get started. Topics covered will include: characteristics of a plan and how these map to components in Postgres code, strategies for producing a minimal reproduction, simple heuristics for developing a reference plan, using the debugger along with several configuration options to examine the plan tree throughout planning, and, finally, adding in your own code.