Re: Why the difference in plans ??

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joost Kraaijeveld" <J(dot)Kraaijeveld(at)Askesis(dot)nl>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Why the difference in plans ??
Date: 2006-09-15 14:08:35
Message-ID: 24190.1158329315@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Joost Kraaijeveld" <J(dot)Kraaijeveld(at)Askesis(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Pallav Kalva 2006-09-15 15:09:35 Optimize SQL
Previous Message Spiegelberg, Greg 2006-09-15 12:43:26 Re: RAID 0 not as fast as expected