Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 6DA822E0064 for ; Tue, 27 Nov 2007 13:26:15 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 70344-05 for ; Tue, 27 Nov 2007 13:26:09 -0400 (AST) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 8749D2E004F for ; Tue, 27 Nov 2007 13:26:09 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id lARHQ8sS024000 for ; Tue, 27 Nov 2007 12:26:08 -0500 (EST) To: pgsql-performance@postgresql.org Subject: Re: Query only slow on first run In-reply-to: <20071127165543.GY11978@crankycanuck.ca> References: <20071127165543.GY11978@crankycanuck.ca> Comments: In-reply-to Andrew Sullivan message dated "Tue, 27 Nov 2007 11:55:43 -0500" Date: Tue, 27 Nov 2007 12:26:08 -0500 Message-ID: <23999.1196184368@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/320 X-Sequence-Number: 27735 Andrew Sullivan writes: > On Tue, Nov 27, 2007 at 05:33:36PM +0100, cluster wrote: >> I have a query that takes about 7000 ms in average to complete the first >> time it runs. Subsequent runs complete in only 50 ms. That is more than >> a factor 100 faster! How can I make the query perform good in the first >> run too? > Probably by buying much faster disk hardware. Or buy more RAM, so that the data can stay cached. regards, tom lane