Re: view row-level locks

From: Vivek Khera <vivek(at)khera(dot)org>
To: Postgres General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: view row-level locks
Date: 2008-07-11 14:44:36
Message-ID: FCD1881E-A6E1-4669-8BE6-D4BCCC0E7A8F@khera.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jul 11, 2008, at 4:24 AM, Richard Huxton wrote:

> If you just want to see if a lock has been taken (e.g. SELECT FOR
> UPDATE) then that shows in pg_locks. If you want details on the
> actual rows involved, then you probably want "pgrowlocks" mentioned
> in Appendix F. Additional Supplied Modules.

pg_locks tells you the page/tuple so you can select it with those
values. Assuming they are page=132 and tuple=44 and relation=99 you
can find the tuple thusly:

select relname from pg_class where oid=99;

then given that relname=mytable,

select * from mytable where ctid='(132,44)';

and there you have the row.

What I need to see is which locks my other queries are waiting on. If
pg_locks would show me which process is also blocking on this lock,
I'd be a much happier man today (actually, last tuesday, when this was
a problem for me to debug something).

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Reyes 2008-07-11 14:47:56 Default fill factor for tables?
Previous Message Augustin Amann 2008-07-11 14:23:36 Re: Update / Lock (and ShareLock) question