Re: pg_advisory_lock(bigint) vs. LOCK TABLE

From: Mark Roberts <mailing_lists(at)pandapocket(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Volkan YAZICI <yazicivo(at)ttmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: pg_advisory_lock(bigint) vs. LOCK TABLE
Date: 2008-07-18 17:22:26
Message-ID: 1216401746.26739.274.camel@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Thu, 2008-07-17 at 12:16 -0400, Alvaro Herrera wrote:
> Volkan YAZICI wrote:
> > Hi,
> >
> > What's the difference between below two queue implementations?
>
> They are two different lock spaces. pg_advisory_lock does not conflict
> with regular system locks, whereas LOCK TABLE does.
>
>
> --
> Alvaro Herrera http://www.CommandPrompt.com/
> The PostgreSQL Company - Command Prompt, Inc.
>

It also appears that advisory locks are tied to your session, where
system locks are tied to your transaction. Also, lock table is a bit
more forceful, because it will affect things that don't bother checking
advisory locks (such as users, manual scripts, buggy applications, etc).

Don't forget that you can use select for update another locking
mechanism as well.

Well, that's my take on it.

-Mark

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Alvaro Herrera 2008-07-18 18:30:15 Re: pg_advisory_lock(bigint) vs. LOCK TABLE
Previous Message Oliveiros Cristina 2008-07-18 14:09:07 Re: How to GROUP results BY month