X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E945D9DCBD1 for ; Wed, 15 Mar 2006 19:21:38 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75171-10 for ; Wed, 15 Mar 2006 19:21:41 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) by postgresql.org (Postfix) with ESMTP id AD2D99DCBD0 for ; Wed, 15 Mar 2006 19:21:35 -0400 (AST) Received: from [192.168.0.5] (unknown [84.12.26.47]) by smtp.nildram.co.uk (Postfix) with ESMTP id C4DD6336403; Wed, 15 Mar 2006 23:21:32 +0000 (GMT) Subject: Re: Slow SELECTS after large update cycle From: Simon Riggs To: Jan de Visser Cc: pgsql-performance@postgresql.org In-Reply-To: <200603151439.13958.jdevisser@digitalfairway.com> References: <200603151439.13958.jdevisser@digitalfairway.com> Content-Type: text/plain Date: Wed, 15 Mar 2006 23:21:27 +0000 Message-Id: <1142464887.3859.195.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.094 required=5 tests=[AWL=0.094] X-Spam-Score: 0.094 X-Spam-Level: X-Archive-Number: 200603/224 X-Sequence-Number: 17661 On Wed, 2006-03-15 at 14:39 -0500, Jan de Visser wrote: > After fixing the hanging problems I reported here earlier (by uninstalling > W2K3 SP1), I'm running into another weird one. > > After doing a +/- 8hr cycle of updates and inserts (what we call a 'batch'), > the first 'reporting' type query on tables involved in that write cycle is > very slow. As an example, I have a query which according to EXPLAIN ANALYZE > takes about 1.1s taking 46s. After this one hit, everything is back to > normal, and subsequent executions of the same query are in fact subsecond. > Restarting the appserver and pgsql does not make the slowness re-appear, only > running another batch will. > > During the 'write'/batch cycle, a large number of rows in various tables are > inserted and subsequently (repeatedly) updated. The reporting type queries > after that are basically searches on those tables. > > Anybody any ideas? This is caused by updating the commit status hint bits on each row touched by the SELECTs. This turns the first SELECT into a write operation. Try running a scan of the whole table to take the hit before you give it back to the users. Best Regards, Simon Riggs