Re: Adding locks statistics

Bertrand Drouvot <bertranddrouvot.pg@gmail.com>

From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Jeff Davis <pgsql@j-davis.com>, Greg Sabino Mullane <htamfids@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2026-02-13T10:24:52Z
Lists: pgsql-hackers

Attachments

Hi,

On Fri, Feb 13, 2026 at 04:36:57PM +0900, Michael Paquier wrote:
> On Tue, Feb 10, 2026 at 07:30:50AM +0000, Bertrand Drouvot wrote:
> > New rebase due to 73d60ac385a.
> 
> I have been looking at this patch, and can get behind the data
> gathered here in terms of being able to tune things

Thanks!

> 
> So my suggestion for the moment would be to be more frugal (yeah I
> know, sorry..) and limit ourselves to four fields: deadlock_timeout,
> requests, fastpath and timeouts.  Three fields to compare with
> requests, one for each GUC.

That's fine by me. We could still add the others in the future if we feel the
need. Done that way in the attached.

> Regarding the implementation, you are right to use a fixed-sized stats
> kind for the job.  I can see a lot of code has been copy-pasted from
> pgstat_io.c, then slightly adjusted to fit into the picture.  That's
> fine here, it makes the implementation straight-forward to read.

Yeah, no need to reinvent the wheel.

> Regarding the documentation, listing all the values for locktype is a
> recipe for rot.  I'd suggest to remove the list instead, with only a
> link referring to pg_locks to avoid the duplication.

Makes sense, done that way. Makes me think that we could do the same for pg_locks
and just link it to the Wait Events of Type Lock? (Table 27.11.)

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 →
  1. Fix injection point detach timing problem in TAP test for lock stats

  2. Use single LWLock for lock statistics in pgstats

  3. Add tests for lock statistics, take two

  4. Remove isolation test lock-stats

  5. Avoid including clog.h in proc.h

  6. Don't include storage/lock.h in so many headers

  7. Add support for lock statistics in pgstats

  8. Move some code blocks in lock.c and proc.c

  9. Move declarations related to locktags from lock.h to new locktag.h