Re: pg_locks "at-a-glance" view

From: David Fetter <david(at)fetter(dot)org>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, Merlin Moncure <mmoncure(at)gmail(dot)com>
Subject: Re: pg_locks "at-a-glance" view
Date: 2008-06-19 13:07:09
Message-ID: 20080619130709.GA30331@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jun 18, 2008 at 05:39:59PM -0700, Jeff Davis wrote:
> I was trying to create a more "at-a-glance" view of the pg_locks table.
> I included the SQL I came up with (after talking to Merlin) at the
> bottom of this message.
>
> The idea is to show any queries that are waiting on a lock, and the
> query that currently holds the lock on which those queries are waiting.
>
> Is my logic correct?

I'm not exactly sure, but it appears to match, at first blush, what's
in src/backend/storage/lmgr/lock.c:
static const LOCKMASK LockConflicts[] = {

> Does anyone have any suggestions?

The function could be in SQL, with one minor bit in PL/PgSQL. File
attached.

> I couldn't find a generally accepted way to do this, although I'm sure
> someone must have done something like this before.

There's stuff in the aforementioned lock.c, but I don't see anything
visible to SQL.

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Attachment Content-Type Size
lock_conflict.sql text/plain 2.4 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dimitri Fontaine 2008-06-19 13:21:07 Re: Inter-app communication via DB
Previous Message Steve Clark 2008-06-19 11:54:07 Re: renumber table