Re: pg_locks view and user locks - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: pg_locks view and user locks
Date
Msg-id 20040913200225.GA5061@dcc.uchile.cl
Whole thread Raw
In response to pg_locks view and user locks  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
Responses Re: [DOCS] pg_locks view and user locks  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Mon, Sep 13, 2004 at 01:34:05PM -0400, Merlin Moncure wrote:

> First, the pg_locks view lists user level locks but doesn't really say
> much about them.  For example, for traditional locks we get the xid but
> for user locks we don't really get anything useful.  I looked in
> lockfuncs.c and didn't see that there would be any real penalty to
> displaying the offset/block of the user lock, and returning it in
> request from pg_locks.

ISTM it would be better to have pg_locks show only system locks, and
another view, say pg_userlocks, to show user locks.  This would allow to
show different data; for example, the PID of the process involved.
What's more, user locks and system locks never conflict, so it seems
wrong to show them together.

Another option would be to add another column to pg_locks to say what
lockmethod (1 for system, 2 for user) is used in each lock.

Maybe we want to separate locks even more, and use one table to show
xact locks, another to show table locks, and yet another to show user
locks.  But maybe this is a bad idea right from the start.

> Is this view frequently queried by system processes?

I don't think there is a lot of server-side stuff (aside from possible
UDFs) that use pg_locks directly.  It's there only for user convenience.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Someone said that it is at least an order of magnitude more work to do
production software than a prototype. I think he is wrong by at least
an order of magnitude."                              (Brian Kernighan)


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: pg_locks view and user locks
Next
From: "Merlin Moncure"
Date:
Subject: Re: pg_locks view and user locks