On 11/05/10 13:32, Carlo Stonebanks wrote:
> Hello all,
>
> A query ran twice in succession performs VERY poorly the first time as
> it iterates through the nested loop. The second time, it rips. Please
> see SQL, SLOW PLAN and FAST PLAN below.
I haven't looked at the details, but the comment you made about it being
fast on the live server which hits this query frequently tends to
suggest that this is a caching issue.
Most likely, the first time Pg has to read the data from disk. The
second time, it's in memory-based disk cache or even in Pg's
shared_buffers, so it can be accessed vastly quicker.
--
Craig Ringer
Tech-related writing: http://soapyfrogs.blogspot.com/