There was some discussion earlier in adding pg_stat_lwlock view in [1].
The main objections which I observed for that patch was showing LWLOCK
information to the user that don't understand what this lock used for and etc.
Currently as part of wait_event information in pg_stat_activity the LWLOCK
information is available to the user and the details of LWLOCk's that are
used in PostgreSQL are also listed in the documentation and with their
purpose.
So I feel it may be worth to add this view to find out the wait times of the
LWLOCK's. This information can be useful to find out the bottlenecks
around LWLOCK's in production environments. But adding the timing calculations
may cause performance problem. Is there any need of writing this stats
information to file? As this just provides the wait time information.
Based on the performance impact with the additional timing calculations,
we can decide the view default behavior, Are there any objections to the
concept?
[1] - https://www.postgresql.org/message-id/4FE9A6F5.2080405@uptime.jp
Regards,
Hari Babu
Fujitsu Australia