Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 538CE9FBC08 for ; Wed, 8 Aug 2007 05:01:12 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 54542-03 for ; Wed, 8 Aug 2007 05:01:03 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from mu-out-0910.google.com (mu-out-0910.google.com [209.85.134.191]) by postgresql.org (Postfix) with ESMTP id D3F239FB817 for ; Wed, 8 Aug 2007 05:01:06 -0300 (ADT) Received: by mu-out-0910.google.com with SMTP id i10so123758mue for ; Wed, 08 Aug 2007 01:01:05 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=m/5wQPm+v1i7EZiZX4vDdVnq6i7XnIEYowby1o4SpTjPavRnx4yqsc49sZJe20V2Ss9cjJuqQPYJm0TVG9+EpiLuPmMlJJ3UBUceoSEr3tvjFS6Aie4/iR/7LompF0OAnd+crm5bbD7RGfQjXRpjguaLf7iLskmuzMwhtf91T4E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=XtSy8npOl4P2Hr+2uTwlIDoXeO6QhIqvgX5BiG9c6XVe70CjrR+ESM6qZ1jxtaPFPHTWnGRwROg7dv2pvwToz69nmrygnBbN5uBIi9xOZYfQrI9MvqPxkBSl3rpbF74kU3w7zHJlZAr0Nzhp5gaV9iVb3GDxjfgrjvIzFiwJ1sk= Received: by 10.86.79.19 with SMTP id c19mr513755fgb.1186560065135; Wed, 08 Aug 2007 01:01:05 -0700 (PDT) Received: from ?192.168.0.199? ( [80.222.48.97]) by mx.google.com with ESMTPS id 28sm664401fkx.2007.08.08.01.01.02 (version=SSLv3 cipher=RC4-MD5); Wed, 08 Aug 2007 01:01:03 -0700 (PDT) Message-ID: <46B97830.1010603@enterprisedb.com> Date: Wed, 08 Aug 2007 09:00:48 +0100 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.10 (X11/20070329) MIME-Version: 1.0 To: Erik Jones CC: Mark Makarowsky , pgsql-performance@postgresql.org Subject: Re: Update table performance References: <670773.87500.qm@web32209.mail.mud.yahoo.com> <1C6EEA75-603F-4B02-8127-920F17AC5411@myemma.com> In-Reply-To: <1C6EEA75-603F-4B02-8127-920F17AC5411@myemma.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/66 X-Sequence-Number: 26196 Erik Jones wrote: > Decibel! wrote: >> I should mention that if you can handle splitting the >> update into multiple transactions, that will help a >> lot since it means you won't be doubling the size of >> the table. > > As I mentioned above, when you do an update you're actually inserting a > new row and deleting the old one. That deleted row is still considered > part of the table (for reasons of concurrency, read up on the > concurrency chapter in the manual for the details) and once it is no > longer visible by any live transactions can be re-used by future > inserts. So, if you update one column on every row of a one million row > table all at once, you have to allocate and write out one million new > rows. But, if you do the update a quarter million at a time, the last > three updates would be able to re-use many of the rows deleted in > earlier updates. Only if you vacuum between the updates. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com