X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 354A152A73 for ; Sat, 6 Aug 2005 10:34:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71348-03 for ; Sat, 6 Aug 2005 13:34:34 +0000 (GMT) Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) by svr1.postgresql.org (Postfix) with ESMTP id 8369C52A71 for ; Sat, 6 Aug 2005 10:34:33 -0300 (ADT) Received: from juju.arbash-meinel.com ([12.214.18.81]) by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP id <20050806133436m9100g6kqae>; Sat, 6 Aug 2005 13:34:36 +0000 Received: by juju.arbash-meinel.com (Postfix, from userid 505) id D437656053; Sat, 6 Aug 2005 08:34:35 -0500 (CDT) Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) by juju.arbash-meinel.com (Postfix) with ESMTP id BEC3956016; Sat, 6 Aug 2005 08:34:31 -0500 (CDT) Message-ID: <42F4BC61.20102@arbash-meinel.com> Date: Sat, 06 Aug 2005 08:34:25 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Patrick Hatcher Cc: "pgsql-performance@postgresql.org" Subject: Re: Slow update statement References: <42F4B812.7070501@comcast.net> In-Reply-To: <42F4B812.7070501@comcast.net> X-Enigmail-Version: 0.92.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigB102F44065A4841D42023663" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.045 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200508/55 X-Sequence-Number: 13802 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB102F44065A4841D42023663 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Patrick Hatcher wrote: > [Reposted from General section with updated information] > Pg 7.4.5 > > I'm running an update statement on about 12 million records using the > following query: > > Update table_A > set F1 = b.new_data > from table_B b > where b.keyfield = table_A.keyfield > > both keyfields are indexed, all other keys in table_A were dropped, yet > this job has been running over 15 hours. Is > this normal? Can you do an EXPLAIN UPDATE so that we can have an idea what the planner is trying to do? My personal concern is if it doing something like pulling in all rows from b, and then one by one updating table_A, but as it is going, it can't retire any dead rows, because you are still in a transaction. So you are getting a lot of old rows, which it has to pull in to realize it was old. How many rows are in table_B? I can see that possibly doing it in smaller chunks might be faster, as would inserting into another table. But I would do more of a test and see what happens. John =:-> > > I stopped the process the first time after 3 hours of running due to > excessive log rotation and reset the conf file to these settings: > > > wal_buffers = 64 # min 4, 8KB each > > # - Checkpoints - > > checkpoint_segments = 128 # in logfile segments, min 1, 16MB each > checkpoint_timeout = 1800 # range 30-3600, in seconds > #checkpoint_warning = 30 # 0 is off, in seconds > #commit_delay = 0 # range 0-100000, in microseconds > #commit_siblings = 5 # range 1-1000 > > > Would it just be quicker to run a JOIN statement to a temp file and then > reinsert? > TIA Patrick > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match > --------------enigB102F44065A4841D42023663 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Darwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFC9LxlJdeBCYSNAAMRAtL9AJ98wz0ruVi1wics+ko476ylNgbT3QCffWN8 arXwBSyM/BCE48I0BmunjUA= =KQQn -----END PGP SIGNATURE----- --------------enigB102F44065A4841D42023663--