Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 812559FB392 for ; Sun, 14 Jan 2007 15:30:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 49228-04-4 for ; Sun, 14 Jan 2007 15:30:37 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 073A59FB3B3 for ; Sun, 14 Jan 2007 15:30:35 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id l0EJUWHH012575; Sun, 14 Jan 2007 14:30:32 -0500 (EST) To: Ken cc: pgsql-sql@postgresql.org Subject: Re: update query taking 24+ hours In-reply-to: <45A9CEA3.3020903@kwasnicki.com> References: <45A9CEA3.3020903@kwasnicki.com> Comments: In-reply-to Ken message dated "Sat, 13 Jan 2007 22:33:07 -0800" Date: Sun, 14 Jan 2007 14:30:32 -0500 Message-ID: <12574.1168803032@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/44 X-Sequence-Number: 27196 Ken writes: > I have postgres 8.1 on a linux box: 2.6Ghz P4, 1.5GB ram, 320GB hard > drive. I'm performing an update between two large tables and so far > it's been running for 24+ hours. > UPDATE Master SET val2=Import.val WHERE Master.x=Import.x AND > Master.y=Import.y; What does EXPLAIN say about that? (Don't try EXPLAIN ANALYZE, but a plain EXPLAIN should be quick enough.) > Both tables have indexes on the x and y columns. Will that help? A two-column index would have helped a lot more, probably, although with so many rows to process I'm not sure that indexes are useful anyway. For really bulk updates a hashjoin or sort-and-mergejoin plan is probably the best bet. BTW, both of those would require plenty of work_mem to run fast ... what have you got work_mem set to? And possibly even more to the point, do you have any foreign key constraints leading into or out of the Master table? regards, tom lane