Re: [HACKERS] pg_locks view and user locks

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Merlin Moncure <merlin(dot)moncure(at)rcsonline(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-docs(at)postgresql(dot)org
Subject: Re: [HACKERS] pg_locks view and user locks
Date: 2004-09-13 20:02:25
Message-ID: 20040913200225.GA5061@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs 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)

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Merlin Moncure 2004-09-13 20:12:32 Re: [HACKERS] pg_locks view and user locks
Previous Message Peter Eisentraut 2004-09-13 19:36:19 Re: pg_locks view and user locks

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2004-09-13 20:12:32 Re: [HACKERS] pg_locks view and user locks
Previous Message Peter Eisentraut 2004-09-13 19:36:19 Re: pg_locks view and user locks