Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 3BC3C9FB2F9 for ; Tue, 10 Apr 2007 13:42:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 21087-07 for ; Tue, 10 Apr 2007 13:42:07 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from www.herakles.homelinux.org (coco2.arach.net.au [203.34.16.107]) by postgresql.org (Postfix) with ESMTP id F083D9FB51D for ; Tue, 10 Apr 2007 13:41:57 -0300 (ADT) Received: from mail.herakles.homelinux.org (unknown [192.168.7.254]) by www.herakles.homelinux.org (Postfix) with ESMTP id 8EBA45F5308 for ; Wed, 11 Apr 2007 00:41:52 +0800 (WST) Received: from mail2.cds.merseine.nu (unknown [192.168.9.4]) by mail.herakles.homelinux.org (Postfix) with ESMTP id C83551EA1B for ; Wed, 11 Apr 2007 00:41:39 +0800 (WST) Received: from [192.168.9.146] (Bilby.demo.lan [192.168.9.146]) by mail2.cds.merseine.nu (Postfix) with ESMTP id 199A6DAC004 for ; Wed, 11 Apr 2007 00:41:24 +0800 (WST) Message-ID: <461BBE33.9030807@herakles.homelinux.org> Date: Wed, 11 Apr 2007 00:41:23 +0800 From: John Summerfield User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20061007 SeaMonkey/1.0.5 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: A long-running transaction References: <461261AD.6060108@herakles.homelinux.org> <20070403201420.GB1519@phlogiston.dyndns.org> In-Reply-To: <20070403201420.GB1519@phlogiston.dyndns.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/110 X-Sequence-Number: 28110 Andrew Sullivan wrote: > On Tue, Apr 03, 2007 at 10:16:13PM +0800, John Summerfield wrote: >> It is hitting the disk pretty hard now on this machine, but the laptop's >> still going too, and the disk seems to run about half the time, part of >> a second running, part idle (but the intervals are getting shorter). >> >> It struck me as fairly curious that neither postgresql nor the >> application was hogging the CPU. > > Why? Nothing about this seems likely CPU bound. It's probably I/O. > I note is number: For the first day or so, the disk light was switching off about half the time. > >> IOwait: 2d 0:46:37.33 28.5% page dea: 16218135 > > which is pretty awful. Also It was some days in before it became so. Eventually, the machines (I kept it running on the laptop because of the amount of RAM plus another) did begin to thrash, but that certainly wasn't the case at first. Note that the proportion of system time is fairly unusual: user : 1d 3:17:04.03 16.0% page in : 131097310 disk 1: 3079516r20087664w nice : 0:05:39.64 0.1% page out: 197016649 system: 2d 20:38:37.13 40.1% page act: 87906251 The Linux kernel's clearly doing a lot of work, and the disk supports DMA and DMA is turned on, so it's not using A PIO mode. According to hdparm, it's using udma5. > >> For each record, I update a non-key field in another table; the source >> data for that other table is less than a megabyte. > > this is a real issue. Basically, you're constrained at the rotation > speed of your disk, because for each record, you have to first find > then update one row somewhere else. It should be in cache: it's all one transaction, and on the laptop, there's over a Gbyte of RAM. Indeed, I would expect postgresql itself to cache it (except the fact it uses so little RAM suggests it doesn't do that at all). > > A >