adding wait_start column to pg_locks - Mailing list pgsql-hackers

From torikoshia
Subject adding wait_start column to pg_locks
Date
Msg-id a96013dc51cdc56b2a2b84fa8a16a993@oss.nttdata.com
Whole thread Raw
Responses Re: adding wait_start column to pg_locks
List pgsql-hackers
Hi,

When examining the duration of locks, we often do join on pg_locks
and pg_stat_activity and use columns such as query_start or
state_change.

However, since these columns are the moment when queries have
started or their state has changed, we cannot get the exact lock
duration in this way.

So I'm now thinking about adding a new column in pg_locks which
keeps the time at which locks started waiting.

One problem with this idea would be the performance impact of
calling gettimeofday repeatedly.
To avoid it, I reused the result of the gettimeofday which was
called for deadlock_timeout timer start as suggested in the
previous discussion[1].

Attached a patch.

BTW in this patch, for fast path locks, wait_start is set to
zero because it seems the lock will not be waited for.
If my understanding is wrong, I would appreciate it if
someone could point out.


Any thoughts?


[1] 
https://www.postgresql.org/message-id/28804.1407907184%40sss.pgh.pa.us

Regards,

--
Atsushi Torikoshi
NTT DATA CORPORATION
Attachment

pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: postgres_fdw - cached connection leaks if the associated user mapping/foreign server is dropped
Next
From: Zhihong Yu
Date:
Subject: Re: postgres_fdw - cached connection leaks if the associated user mapping/foreign server is dropped