Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 52FB39FA354; Wed, 6 Dec 2006 14:09:35 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 15843-01; Wed, 6 Dec 2006 14:09:26 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from myemma.com (db1.e2ma.net [66.179.147.163]) by postgresql.org (Postfix) with ESMTP id A6F519FA344; Wed, 6 Dec 2006 14:09:27 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by myemma.com (Postfix) with ESMTP id 471B523CE9; Wed, 6 Dec 2006 12:09:25 -0600 (CST) Received: from myemma.com ([127.0.0.1]) by localhost (velma [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 31271-10; Wed, 6 Dec 2006 12:09:24 -0600 (CST) Received: from [10.0.23.59] (unknown [209.149.59.218]) by myemma.com (Postfix) with ESMTP id 8A8C023CDC; Wed, 6 Dec 2006 12:09:24 -0600 (CST) Message-ID: <45770754.8030500@myemma.com> Date: Wed, 06 Dec 2006 12:09:24 -0600 From: Erik Jones User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: Casey Duncan Cc: Joost Kraaijeveld , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] Locking in PostgreSQL? References: <1165388652.6396.1.camel@panoramix> <433FC6DE-EF5C-493A-967C-C1B0F1882C23@pandora.com> In-Reply-To: <433FC6DE-EF5C-493A-967C-C1B0F1882C23@pandora.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at myemma.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/274 X-Sequence-Number: 105213 Casey Duncan wrote: > On Dec 5, 2006, at 11:04 PM, Joost Kraaijeveld wrote: > >> Does PostgreSQL lock the entire row in a table if I update only 1 >> column? > > Know that updating 1 column is actually updating the whole row. So if > one transaction updates column A of a row, it will block another > concurrent transaction that tries to update column B of the same row. > As was mentioned however, neither of these transactions block others > reading the row in question, though they see the row as it existed > before the updates until those update transactions commit. > > If you know that your application will suffer excessive update > contention trying to update different columns of the same row, you > could consider splitting the columns into separate tables. This is an > optimization to favor write contention over read performance (since > you would likely need to join the tables when selecting) and I > wouldn't do it speculatively. I'd only do it if profiling the > application demonstrated significantly better performance with two > tables. > > -Casey Or, come up with some kind of (pre)caching strategy for your updates wherein you could then combine multiple updates to the same row into one update. -- erik jones software development emma(r)