Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id E1D986339D2 for ; Thu, 7 Jan 2010 03:49:42 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 50250-02 for ; Thu, 7 Jan 2010 07:49:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f226.google.com (mail-ew0-f226.google.com [209.85.219.226]) by mail.postgresql.org (Postfix) with ESMTP id 1DF8463344B for ; Thu, 7 Jan 2010 03:49:31 -0400 (AST) Received: by ewy26 with SMTP id 26so16341585ewy.3 for ; Wed, 06 Jan 2010 23:49:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=bN9QuMpYfB9L4A0b1hlbt9UkP2z3+enyGdQl22eAOlE=; b=sBE2ykVXSVfGXW2d4rVMZxmFDcY66heG8lyXjkV0MKnCoi94mmXHMQGBnI02GlR2Mc 2J/5l7tLIhXdxp8c1VsSWLnU+/WPad1BbywS97am6NrDtKZQxFpJZMTkI7gFEfpxdCWq vrB4DDTlqqO4L19D2BUKnmlYRNvRIy6givQFU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=fwYxoaUznDmg8OqoGD5MCt+nAdvxLHz8Hw6ESQcrzUaLQQUkj0Seln7qPhHnojSg6I Fs28pI91CZI3pCeHOrxyB9ZfFCoGjFTbO6G2xBmvfFdUqmC/rmZENxTh+K8dgewtN8CN AAJsSf9+OoATOXJ6DkxVk642gpkvLfaHiQ+e8= MIME-Version: 1.0 Received: by 10.216.90.137 with SMTP id e9mr618107wef.141.1262850570322; Wed, 06 Jan 2010 23:49:30 -0800 (PST) In-Reply-To: References: Date: Thu, 7 Jan 2010 00:49:30 -0700 Message-ID: Subject: Re: Massive table (500M rows) update nightmare From: Scott Marlowe To: Carlo Stonebanks Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.589 tagged_above=-10 required=5 tests=BAYES_00=-2.599, FH_DATE_PAST_20XX=3.188 X-Spam-Level: X-Archive-Number: 201001/78 X-Sequence-Number: 36958 On Thu, Jan 7, 2010 at 12:17 AM, Carlo Stonebanks wrote: > Our DB has an audit table which is 500M rows and growing. (FYI the objects > being audited are grouped semantically, not individual field values). > > Recently we wanted to add a new feature and we altered the table to add a > new column. We are backfilling this varchar(255) column by writing a TCL > script to page through the rows (where every update is a UPDATE ... WHERE id >>= x AND id < x+10 and a commit is performed after every 1000 updates > statement, i.e. every 10000 rows.) > > We have 10 columns, six of which are indexed. Rough calculations suggest > that this will take two to three weeks to complete on an 8-core CPU with > more than enough memory. > > As a ballpark estimate - is this sort of performance for an 500M updates > what one would expect of PG given the table structure (detailed below) or > should I dig deeper to look for performance issues? Got an explain analyze of the delete query?