Great Stack to Doesn't Work #1 PostgreSQL: "I Added an Index and It Got Slower" A survival guide for when everything goes wrong in production. You've been there. The query is slow. You check the table — no index on the WHERE clause column. You add one. You deploy. You check again. It's slower. Not a little slower. Ten times slower. Your index, the thing that was supposed to fix everything, just made it worse. And now your PM is asking why the dashboard takes 14 seconds to load. Welcome to PostgreSQL's query planner. It has opinions, and it doesn't care about yours. The Query Planner Has a Plan (And It's Not Yours) PostgreSQL doesn't just "use your index." It makes a decision. Every single time a query runs, the planner evaluates dozens of possible execution strategies and picks the one it thinks will be cheapest. Key word: thinks . The planner uses statistics — pg_statistic stores data distribution info for every column. How many distinct values? What's the most common value?…