Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 5BFBF2E0047 for ; Thu, 27 Mar 2008 14:08:12 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 91932-10 for ; Thu, 27 Mar 2008 14:08:07 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mx00.pub.collaborativefusion.com (mx00.pub.collaborativefusion.com [206.210.89.199]) by postgresql.org (Postfix) with ESMTP id BBE482E0031 for ; Thu, 27 Mar 2008 14:08:07 -0300 (ADT) Received: from vanquish.ws.pitbpa0.priv.collaborativefusion.com (vanquish.ws.pitbpa0.priv.collaborativefusion.com [192.168.2.162]) (SSL: TLSv1/SSLv3,256bits,AES256-SHA) by wingspan with esmtp; Thu, 27 Mar 2008 13:08:10 -0400 id 00056410.47EBD47A.00014FBF Date: Thu, 27 Mar 2008 13:07:44 -0400 From: Bill Moran To: "Jesper Krogh" Cc: pgsql-performance@postgresql.org Subject: Re: "Slow" query or just "Bad hardware"? Message-Id: <20080327130744.9bef536b.wmoran@collaborativefusion.com> In-Reply-To: <17799.195.41.66.226.1206632068.squirrel@mail.jabbernet.dk> References: <17799.195.41.66.226.1206632068.squirrel@mail.jabbernet.dk> Organization: Collaborative Fusion X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.8; i386-portbld-freebsd6.3) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/505 X-Sequence-Number: 29459 In response to "Jesper Krogh" : > Hi > > I have a table with around 10 million entries The webpage rendered hits > at most 200 records which are distributed well in the 10m with an average > of 2 "references" pr. entry. > > Is there anyway to speed this query more up than allready. .. yes running > it subsequenctly it is blazingly fast, but with view of around 200/10m we > most > often dont hit the same query again. While all the other advice is good, what you really need to do to address this is figure out what's in your cache and whether it's the right things. Once you _know_ that (and aren't just speculating) you can start to use the solutions that others have suggested to improve on the situation. If you just start trying things at random, you'll probably figure it out eventually anyway, but I'm assuming you'll want a direct route. So, I'm going to repeat something that I say on this mailing list about twice a month: install MRTG or some equivalent and start graphing critical database statistics. In your case, install the pg_buffercache addon and use it to track how much of your shared buffers each table is using. Based on your description of the problem, I doubt it will take more than a few days to have a clear view of exactly what's going on (i.e. you'll probably see table X clearing table Y out of the buffers or something ...)