Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D9A8E9FB7A9 for ; Thu, 28 Jun 2007 03:39:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 99086-03 for ; Thu, 28 Jun 2007 03:39:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id E4E2B9FB6FE for ; Thu, 28 Jun 2007 03:39:51 -0300 (ADT) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id AC46573C7D; Thu, 28 Jun 2007 07:39:46 +0100 (BST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 3254D2740E5; Thu, 28 Jun 2007 07:39:53 +0100 (BST) Message-ID: <468357B2.1040205@archonet.com> Date: Thu, 28 Jun 2007 07:39:46 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: Chris Cc: Tom Lane , Pgsql performance Subject: Re: update query taking too long References: <46834124.5010600@gmail.com> <21072.1183009270@sss.pgh.pa.us> <46835252.5070901@gmail.com> In-Reply-To: <46835252.5070901@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/616 X-Sequence-Number: 25649 Chris wrote: > Tom Lane wrote: >> Any foreign keys leading to or from that table? > > Nope :( > >> 3.5 million row updates are not exactly gonna be instantaneous anyway, >> but only FK checks or really slow user-written triggers would make it >> take upwards of an hour ... > > No triggers, functions. Of course you really want a trigger on this, since presumably domainname should always be kept in sync with emailaddress. But that's not the immediate issue. > Table is pretty basic. > > I have a few indexes (one on the primary key, one on emailaddress etc) > but the 'domainname' column is a new one not referenced by any of the > indexes. > > FWIW (while the other update is still going in another window): What's saturated? Is the system I/O limited or CPU limited? You *should* be limited by the write speed of your disk with something simple like this. What happens if you do the following? CREATE TABLE email_upd_test (id SERIAL, email text, domainname text, PRIMARY KEY (id)); INSERT INTO email_upd_test (email) SELECT n::text || '@' || n::text FROM (SELECT generate_series(1,1000000) AS n) AS numbers; ANALYSE email_upd_test; \timing UPDATE email_upd_test SET domainname=substring(email from position('@' in email)); UPDATE 1000000 Time: 35056.125 ms That 35 seconds is on a simple single-disk IDE disk. No particular tuning done on that box. -- Richard Huxton Archonet Ltd