Re: [PERFORM] Locking in PostgreSQL?

From: Erik Jones <erik(at)myemma(dot)com>
To: Casey Duncan <casey(at)pandora(dot)com>
Cc: Joost Kraaijeveld <J(dot)Kraaijeveld(at)Askesis(dot)nl>, pgsql-general(at)postgresql(dot)org, pgsql-performance(at)postgresql(dot)org
Subject: Re: [PERFORM] Locking in PostgreSQL?
Date: 2006-12-06 18:09:24
Message-ID: 45770754.8030500@myemma.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

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 <erik(at)myemma(dot)com>
software development
emma(r)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bob Pawley 2006-12-06 18:26:50 From Clause
Previous Message Casey Duncan 2006-12-06 17:58:37 Re: [PERFORM] Locking in PostgreSQL?

Browse pgsql-performance by date

  From Date Subject
Next Message Michael Stone 2006-12-06 18:11:53 Re: File Systems Compared
Previous Message Steinar H. Gunderson 2006-12-06 18:08:12 [offtopic] Word wrapping