Re: Proposal: expose heavyweight lock wait start time in pg_stat_activity - Mailing list pgsql-hackers

From shihao zhong
Subject Re: Proposal: expose heavyweight lock wait start time in pg_stat_activity
Date
Msg-id CAGRkXqR+WkkRowsucXwb_ncZvNAm4dqU5TBa2Asjro2W2spDNw@mail.gmail.com
Whole thread
In response to Re: Proposal: expose heavyweight lock wait start time in pg_stat_activity  (Sami Imseih <samimseih.pg@gmail.com>)
Responses Re: Proposal: expose heavyweight lock wait start time in pg_stat_activity
List pgsql-hackers
Hi Alex,

> pg_locks.waitstart already provides this information. Any reason that
> is not sufficient?

I agree with Sami here. A backend waits on at most one lock at a time,
so a view on your side gives you the same thing today:

CREATE VIEW my_activity AS
SELECT a.*, l.waitstart AS lock_wait_start
FROM pg_stat_activity a
LEFT JOIN pg_locks l ON l.pid = a.pid AND NOT l.granted;

The only thing that view cannot give you is avoiding the lock manager
scan pg_locks does on every read. I do not think that is an issue
unless something queries the view very often, like a monitoring agent
sampling every second. If that is your case, please show numbers for
it. That is the case the patch would need to make.

Thanks,
Shihao


pgsql-hackers by date:

Previous
From: shihao zhong
Date:
Subject: Re: Add a permission check to pg_stat_get_backend_subxact()
Next
From: Bharath Rupireddy
Date:
Subject: Re: Support for 8-byte TOAST values, round two