pg_plan_alternatives: Tracing PostgreSQL Query Plan Alternatives Using eBPF (jnidzwetzki.github.io)

The article introduces pg_plan_alternatives, a tool that uses eBPF to trace PostgreSQL’s cost-based query planner and record not just the final chosen plan but also the alternative plan paths and their estimated costs. It explains how PostgreSQL generates multiple alternatives during planning, how pg_plan_alternatives instruments the optimizer to capture them, and how it visualizes the results as a graph. The post also discusses implementation details like reading needed path fields from PostgreSQL binaries via DWARF offsets and shows example commands and potential uses for tuning planner parameters.

April 02, 2026 02:24 Source: Hacker News