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).