From: | Markus Schiltknecht <markus(at)bluegap(dot)ch> |
---|---|
To: | Dave Cramer <pg(at)fastcrypt(dot)com> |
Cc: | Jens Schipkowski <jens(dot)schipkowski(at)apus(dot)co(dot)at>, 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 13:42:32 |
Message-ID: | 4576C8C8.7060301@bluegap.ch |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-performance |
Hi,
Dave Cramer wrote:
> Apparently I've completely misunderstood MVCC then....
Probably not. You are both somewhat right.
Jens Schipkowski wrote:
>> Thats not right. UPDATE will force a RowExclusiveLock to rows
>> matching the WHERE clause, or all if no one is specified.
That almost right, RowExclusiveLock is a table level lock. An UPDATE
acquires that, yes. Additionally there are row-level locks, which is
what you're speaking about. An UPDATE gets an exclusive row-level lock
on rows it updates.
Please note however, that these row-level locks only block concurrent
writers, not readers (MVCC lets the readers see the old, unmodified row).
> My understanding
> is that unless you do a select ... for update then update the rows will
> not be locked.
Also almost right, depending on what you mean by 'locked'. A plain
SELECT acquires an ACCESS SHARE lock on the table, but no row-level
locks. Only a SELECT ... FOR UPDATE does row-level locking (shared ones
here...)
The very fine documentation covers that in [1].
Regards
Markus
[1]: PostgreSQL Documentation, Explicit Locking:
http://www.postgresql.org/docs/8.2/interactive/explicit-locking.html
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2006-12-06 13:45:27 | Re: [PERFORM] Locking in PostgreSQL? |
Previous Message | Steinar H. Gunderson | 2006-12-06 13:31:04 | Re: Locking in PostgreSQL? |
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2006-12-06 13:45:27 | Re: [PERFORM] Locking in PostgreSQL? |
Previous Message | Steinar H. Gunderson | 2006-12-06 13:31:04 | Re: Locking in PostgreSQL? |