Hi,
>
> I'd like to propose exposing the start time of the current heavyweight lock wait in pg_stat_activity, perhaps as:
>
> lock_wait_start timestamptz
>
> pg_stat_activity currently tells us that a backend is waiting on a lock through wait_event_type and wait_event, but
notwhen that wait started.
pg_locks.waitstart already provides this information. Any reason that
is not sufficient?
pg_locks is meant to be joined with pg_stat_activity anyhow. The two
views aren't read
from the same snapshot, so they can be out of sync. But that's already
true inside
pg_stat_activity, as the docs say:
"To keep the reporting overhead low, the system does
not attempt to synchronize different aspects of activity data for a
backend. As a result,
ephemeral discrepancies may exist between the view's columns."
The same will be true even if we add waitstart to pg_stat_activity.
--
Sami Imseih
Amazon Web Services (AWS)