Re: Why the difference in plans ?? - Mailing list pgsql-performance

From Tom Lane
Subject Re: Why the difference in plans ??
Date
Msg-id 24190.1158329315@sss.pgh.pa.us
Whole thread Raw
In response to Why the difference in plans ??  ("Joost Kraaijeveld" <J.Kraaijeveld@Askesis.nl>)
Responses Re: Why the difference in plans ??  (Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>)
List pgsql-performance
"Joost Kraaijeveld" <J.Kraaijeveld@Askesis.nl> writes:
> Why the difference and can I influence the result so that the first
> query plan (which is the fastest) is actually used in both cases (I
> would expect that the limit would be done after the sort?)?

It likes the second plan because 6694025.41/353 < 41812.78.  It would
probably be right, too, if the number of matching rows were indeed 353,
but it seems there are only 7.  Try increasing your statistics target
and re-analyzing.

            regards, tom lane

pgsql-performance by date:

Previous
From: "Spiegelberg, Greg"
Date:
Subject: Re: RAID 0 not as fast as expected
Next
From: Pallav Kalva
Date:
Subject: Optimize SQL