Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id F271D64FC01 for ; Thu, 25 Sep 2008 16:35:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 88060-07 for ; Thu, 25 Sep 2008 16:35:22 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from qb-out-0506.google.com (qb-out-0506.google.com [72.14.204.227]) by postgresql.org (Postfix) with ESMTP id 5A24164FC4A for ; Thu, 25 Sep 2008 16:35:22 -0300 (ADT) Received: by qb-out-0506.google.com with SMTP id d8so415743qbc.23 for ; Thu, 25 Sep 2008 12:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=2atYzKHNqdAeAzC600CnpH3p39fzGT6qLpDKUh3lQZY=; b=HlcvumVZ1vLUQIQlmemz5/L8Ok+7+lhfEfRpc4mLPRz88f8wzakqqRGNwuSL2W2IOd b0AsdR7kAMZ77w7XtqHXSQmQQ13T+Tj5T2CLk8x0JYslniVm2KXw6ZW5INyXbqSNyiI7 m+DPx3bKCsPDIBUIU/q/gq4s9TO5Xyrx5Yhsk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=IOyamKQkCbSUOeCdQXDyZCNN/qQRIETyAoBPTBMk2LJxmJXGwYpIoivp9POUIoZjjW pLND6xMF/e2oDd4b72kKxcBMuik8OopCnU3s8/MPKsQ5bt94vcL3hm2WyKlPcQ8Eq76m IXn6JS0MCPB2eItRArq2nKEGNPprD79IeXDfE= Received: by 10.141.49.18 with SMTP id b18mr93824rvk.92.1222371319921; Thu, 25 Sep 2008 12:35:19 -0700 (PDT) Received: by 10.141.74.11 with HTTP; Thu, 25 Sep 2008 12:35:19 -0700 (PDT) Message-ID: Date: Thu, 25 Sep 2008 13:35:19 -0600 From: "Scott Marlowe" To: "John Huttley" Subject: Re: Slow updates, poor IO Cc: pgsql-performance@postgresql.org, "Dan Langille" In-Reply-To: <48DBE587.3050406@mib-infotech.co.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48DBE587.3050406@mib-infotech.co.nz> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/226 X-Sequence-Number: 31539 On Thu, Sep 25, 2008 at 1:24 PM, John Huttley wrote: > I've just had an interesting encounter with the slow full table update > problem that is inherent with MVCC > > The system is 64 bit linux with 2.6.25 kernel feeding scsi disks. > > the table is > > CREATE TABLE file ( > fileid integer NOT NULL, > fileindex integer DEFAULT 0 NOT NULL, > jobid integer NOT NULL, > pathid integer NOT NULL, > filenameid integer NOT NULL, > markid integer DEFAULT 0 NOT NULL, > lstat text NOT NULL, > md5 text NOT NULL, > perms text > ); > > ALTER TABLE ONLY file > ADD CONSTRAINT file_pkey PRIMARY KEY (fileid); > > CREATE INDEX file_fp_idx ON file USING btree (filenameid, pathid); > CREATE INDEX file_jobid_idx ON file USING btree (jobid); > > There are 2.7M rows. > > running update file set perms='0664' took about 10 mins So, how many rows would already be set to 0664? Would adding a where clause speed it up? update file set perms='0664' where perms <> '0664'; > during this period, vmstat reported Blocks Out holding in the 4000 to 6000 > range. > > > When I dropped the indexes this query ran in 48sec. > Blocks out peaking at 55000. > > So there is a double whammy. > MVCC requires more work to be done when indexes are defined and then this > work > results in much lower IO, compounding the problem. That's because it becomes more random and less sequential. If you had a large enough drive array you could get that kind of performance for updating indexes, since the accesses would tend to hit different drives most the time. Under heavy load on the production servers at work we can see 30 to 60 Megs a second random access with 12 drives, meaning 2.5 to 5Megs per second per drive. Sequential throughput is about 5 to 10 times higher. What you're seeing are likely the effects of running a db on insufficient drive hardware.