Re: Planner picks the wrong plan? - Mailing list pgsql-performance

From Tom Lane
Subject Re: Planner picks the wrong plan?
Date
Msg-id 20687.1097033396@sss.pgh.pa.us
Whole thread Raw
In response to Planner picks the wrong plan?  (Nichlas Löfdahl <crotalus@acc.umu.se>)
List pgsql-performance
Nichlas =?iso-8859-1?Q?L=F6fdahl?= <crotalus@acc.umu.se> writes:
> My question is, why doesn't the planner pick the same plan for Q1 & Q3?

I think it's mostly that after you've added and ANALYZEd the "age"
column, the planner has a pretty good idea of how many rows will pass
the "age > 17 AND age < 20" condition.  It can't do very much with the
equivalent condition in the original form, though, and in fact ends up
drastically underestimating the number of matching rows (86 vs reality
of 3021).  That leads directly to a bad plan choice :-(

            regards, tom lane

pgsql-performance by date:

Previous
From: Max Baker
Date:
Subject: test post
Next
From: Alan Stange
Date:
Subject: Re: Excessive context switching on SMP Xeons