Re: table locks

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ilejn(at)yandex(dot)ru
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: table locks
Date: 2006-12-26 14:59:46
Message-ID: 3675.1167145186@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Ilja Golshtein" <ilejn(at)yandex(dot)ru> writes:
> I need table level locks for cooperative usage in my application.

> LOCK TABLE table_name in EXCLUSIVE MODE
> and
> LOCK TABLE table_name in SHARED MODE
> perfectly suit my needs.

The question is *why* you feel you need that, ie what are you using
these for? As was already mentioned upthread, it's usually better
to avoid explicit locking altogether, if you can.

> The only drawback - interference with VACUUM and other system processes
> with obvious performance/response time penalty.

I can hardly imagine an ordinary lock type that doesn't conflict with
anything at all ... ALTER/DROP TABLE being the obvious counterexamples.
If you don't want your "shared" lock to conflict with VACUUM then you
could use ACCESS SHARE instead of SHARE, and it would still block
EXCLUSIVE.

> Honestly I've already introduced such locks with syntax
> LOCK TABLE table_name in APPLICATION EXCLUSIVE MODE
> and
> LOCK TABLE table_name in APPLICATION SHARED MODE
> Does publishing of this patch make any sense?

It's quite unlikely to get accepted, considering that advisory locks
already seem to cover the territory. (8.2 has blocking versions of
those calls BTW.)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shoaib Mir 2006-12-26 15:06:38 Re: Clustering & Load Balancing & Replication
Previous Message Andy Dale 2006-12-26 14:41:02 Re: Clustering & Load Balancing & Replication