Re: Adding locks statistics
Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Michael Paquier <michael@paquier.xyz>, Jeff Davis <pgsql@j-davis.com>, Greg Sabino Mullane <htamfids@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2026-02-17T16:33:54Z
Lists: pgsql-hackers
Attachments
- v5-0001-Add-lock-statistics.patch (text/x-diff)
Hi, On Mon, Feb 16, 2026 at 04:00:56PM -0500, Andres Freund wrote: > Hi, > > On 2026-02-16 10:10:21 +0000, Bertrand Drouvot wrote: > > Yeah, providing the wait_time would be great. Just to be sure, are you suggesting > > to remove all the fields (i.e requests, timeouts, deadlock_timeouts and fastpath) > > and just add a wait_time field instead? > > Well, I'd maybe make it waits, wait_time and perhaps fastpath exceeded. Okay, done that way in the attached. To avoid overhead due to timing as much as possible, the patch simply relies on log_lock_waits and deadlock_timeout. It means that it relies on the existing code, and increments waits and wait_time only if log_lock_waits is on and if the session waited longer than deadlock_timeout. I did not want to dissociate the waits and wait_time increments so that their ratio could still make sense. That sounds like a good compromise, thoughts? > > I think that keeping requests would make sense to be able to get the average > > wait time per request. > > I don't think I'd request for that (as that would require counting in the > normal case), I'd use the number of waits. Yeah, I meant to say waits and not requests. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix injection point detach timing problem in TAP test for lock stats
- 3284e3f63cf0 19 (unreleased) landed
-
Use single LWLock for lock statistics in pgstats
- 404a17c155ac 19 (unreleased) landed
-
Add tests for lock statistics, take two
- 557a9f1e3e62 19 (unreleased) landed
-
Remove isolation test lock-stats
- 7c64d56fd976 19 (unreleased) landed
-
Avoid including clog.h in proc.h
- f227b7b20c36 19 (unreleased) landed
-
Don't include storage/lock.h in so many headers
- 2102ebb1953f 19 (unreleased) landed
-
Add support for lock statistics in pgstats
- 4019f725f5d4 19 (unreleased) landed
-
Move some code blocks in lock.c and proc.c
- a90d86518243 19 (unreleased) landed
-
Move declarations related to locktags from lock.h to new locktag.h
- 322bab79744d 19 (unreleased) landed