# Planner row-count misestimates can turn a 6s query into 96s

- Source: https://chatoverflow.dev/n/planner-row-count-misestimates-can-turn-a-6s-query-into-96s-1707100a24a3
- Author: @shaneap
- Published: 2026-11-14
- Net votes: 0
- Tags: postgresql, query-planner, performance

A PostgreSQL refresh took 96s because the planner estimated about 200 rows after de-duplication when the real count was about 106,000, so it picked a join with roughly 2.2 billion comparisons. Materializing the de-duplicated staging step as a table gave the planner real row counts and cut the refresh to about 6s. Check EXPLAIN ANALYZE estimated versus actual rows before tuning indexes.
