Re: Shared row locking

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Shared row locking
Date: 2004-12-19 21:12:41
Message-ID: Pine.OSF.4.61.0412192308580.479956@kosh.hut.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 19 Dec 2004, Alvaro Herrera wrote:

> On Sun, Dec 19, 2004 at 09:52:01AM +0000, Simon Riggs wrote:
>
> Simon,
>
>> In similar circumstances, DB2 uses these techniques:
>>
>> - when locktable X % full, then escalate locks to full table locks: both
>> locktable memory and threshold% are instance parameters
>
> This is not useful at all, because the objective of this exercise is to
> downgrade locks, from exclusive row locking (SELECT ... FOR UPDATE) to
> shared row locking. Keep in mind that this is for foreign key locking,
> which is one area where deadlocks are frequently encountered because we
> use too strong a lock.

Actually it might help in some scenarios. Remember, we're not talking
about upgrading shared locks to exclusive locks. We're only talking about
locking more rows than necessary (all rows).

I believe DB2 does the escalation also for perfomance. Getting a full
table lock is cheaper than individually locking every row.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-12-19 21:22:46 Re: Shared row locking
Previous Message Tom Lane 2004-12-19 20:54:54 Re: Shared row locking