Re: pg_advisory_lock(bigint) vs. LOCK TABLE

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Mark Roberts <mailing_lists(at)pandapocket(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 18:30:15
Message-ID: 20080718183015.GH4042@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Mark Roberts wrote:
>
> 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.
>
> It also appears that advisory locks are tied to your session, where
> system locks are tied to your transaction.

Now that you mention that, I recall that the other important difference
is that you can release pg_advisory_lock anytime you want. With LOCK
TABLE it always happens automatically at transaction commit (and there's
no UNLOCK TABLE).

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Karl Denninger 2008-07-20 03:15:30 Whassup with this? (create table .... like ... fails)
Previous Message Mark Roberts 2008-07-18 17:22:26 Re: pg_advisory_lock(bigint) vs. LOCK TABLE