Why does the planner get row-count estimates wrong?

PostgreSQL estimated that a filter would return 100 rows, but it actually returned 100,000. How does the planner estimate row counts, and why might its estimate be so far off? Explain how this error could affect the execution plan and suggest specific checks to investigate it. Simply recommending an index without examining the cause isn't enough.

ExplainEXPLAIN and optimizationMiddleBackendData EngineerAnalyst