Re: Adding locks statistics - Mailing list pgsql-hackers

From Greg Sabino Mullane
Subject Re: Adding locks statistics
Date
Msg-id CAKAnmm+USTr5MeKuyrAvbCjHqbSFbZ+czJsV7fPYt9nECQkf-A@mail.gmail.com
Whole thread Raw
In response to Adding locks statistics  (Bertrand Drouvot <bertranddrouvot.pg@gmail.com>)
Responses Re: Adding locks statistics
Re: Adding locks statistics
List pgsql-hackers
Great idea. +1. Here is a quick overall review to get things started.

Meta:
patch did not apply via "git apply". Also has carriage returns (e.g. DOS file), and some errant whitespace. Seems to pass pgindent, though.

Name:
I think the name would read better as pg_stat_locks, especially as it returns multiple rows.

Docs: seem good. Needs a section on how to reset via
SELECT pg_stat_reset_shared('lock');
Also plural better here ('locks')

Code:

+ * Copyright (c) 2021-2025, PostgreSQL Global Development Group

If a new file, we can simply say 2025?

+ LWLock locks[LOCKTAG_LAST_TYPE + 1];
+ PgStat_Lock stats;

Adding a lock to the system that counts locks! :) (just found amusing, not a comment)

-#define PGSTAT_KIND_SLRU 11
-#define PGSTAT_KIND_WAL 12
+#define PGSTAT_KIND_LOCK 11
+#define PGSTAT_KIND_SLRU 12
+#define PGSTAT_KIND_WAL 13

Why not just add LOCK as #13?

What about the overhead of maintaining this system? I know it's overall very lightweight, but from my testing, the relation locktype in particular is very, very busy. Busier than I realized until I saw it in this useful view!

Cheers,
Greg

--
Enterprise Postgres Software Products & Tech Support

pgsql-hackers by date:

Previous
From: Doruk Yilmaz
Date:
Subject: Re: [Patch] add new parameter to pg_replication_origin_session_setup
Next
From: Robert Haas
Date:
Subject: Re: Extension security improvement: Add support for extensions with an owned schema