Andres Freund <andres@anarazel.de> writes:
> On 2019-11-08 14:49:25 +0800, Craig Ringer wrote:
>> I recently found the need to pretty-print the contents of pg_locks. So
>> here's a little helper to do it, for anyone else who happens to have that
>> need. pg_identify_object is far from adequate for the purpose. Reckon I
>> should turn it into C and submit?
> Yea, I think we need to make it easier for users to understand
> locking. I kind of wonder whether part of the answer would be to change
> the details that pg_locks shows, or add a pg_locks_detailed or such
> (presumably a more detailed version would include walking the dependency
> graph to at least some degree, and thus more expensive).
I think the actual reason why pg_locks is so bare-bones is that it's
not supposed to require taking any locks of its own internally. If,
for example, we changed the database column so that it requires a lookup
in pg_database, then the view would stop working if someone had an
exclusive lock on pg_database --- pretty much exactly the kind of case
you might wish to be investigating with that view.
I don't have any objection to adding a more user-friendly layer
to use for normal cases, but I'm hesitant to add any gotchas like
that into the basic view.
regards, tom lane