Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ulWku-002C2l-Ol for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Aug 2025 17:56:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ulWjt-002kWZ-6s for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Aug 2025 17:55:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ulWjs-002kWR-Tk for pgsql-hackers@lists.postgresql.org; Mon, 11 Aug 2025 17:55:17 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ulWjq-0003uR-25 for pgsql-hackers@lists.postgresql.org; Mon, 11 Aug 2025 17:55:16 +0000 Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-3dc9e7d10bdso12549215ab.2 for ; Mon, 11 Aug 2025 10:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754934913; x=1755539713; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=lVensRAGVfsgIl7A3KLs52f9ihGtgP9eS9JEi0invOo=; b=lEHpR+FmTyc/KVXxM+kPZ1QEvwFO0HXpHZGeFz+H7ixgfGQClu8BfKY4Vqc4tB9No3 /KzguAUMOzOUmv5QRbdWR78zeG72KqSssOo2ufaAigfAaLd9YdORwx8MoacOLxk60qra CWkDHaE7E5pIYRWIvpGQvoQ3GKxH7foB+juSP5hrfwJktkCaY2ay9boLOoPueU/EZMOh y9/LXjUkkrlSwzAPg3JTPu+8GQcIN7Oxg138RtGtYeB5fpeNwgKzVZ++ZEPEUvxbafPK vWA66SzG3OWDapZ/Oxj9yjdXwF+zrElCL2+liLGD6dHODIqr5xr+uW01/Cl6al02f7eo JFxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754934913; x=1755539713; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lVensRAGVfsgIl7A3KLs52f9ihGtgP9eS9JEi0invOo=; b=IfeHvhoHUdtvzqWNYNaKwaTitfY7/EoC/LeaPUzDShgpl/J7LcWQuXlC+Pc3CiuIkY D9NGWUVR2stAI00ED1nNHOIUsQEYqzKDEG+FELrUKp4jyskjb3iQ8QCwUM54K2GfzOMd Gt5MKO4O5y2Eb84OlP2gv3GIq5VnP5F8bUEACsmPJhTORtnJZ0qijVNDkaYqSDZU6B23 hwvaxD0u93NLaZ5lNsBdu9wBuUrT4ynTb6JIMZ2gL4FkxqhxBEb9HVOZfbfnzxWHPhBa fMjmlVFUon0n+jl88psi6ZXeQZj6AqYpU9gayDkY9LZohTkswQz/HGIU02F7KjdTh3P5 vFIw== X-Gm-Message-State: AOJu0YyDNqrfLNz74ivYvpPaaz2GiBRwIIB2pTBDGs57yjEpbKsf6t4R BocUOLIySidLSUbzR+oGExW+9FxXT/zbLoFHoke4filbT7BNduGgnNNs0LEDLOdfnIhsP8shSpw cr0sDR2K6SDoMLFi95GMUjfzaq+oXKs0= X-Gm-Gg: ASbGncs5iweSj7IkA10+cAEu8fTg9qUopavsGR/sphp1oZErFCwvz9fRbSTevc8CWg1 2wn5WvlcDppJ4772dWSXWL9YMkLJwlrhm+o3HXfHNyiylFro7I+r+J2ajo3ouGX9bW0ojMuhyCn BJ9CtnigHv04E4lTmgX5JjW0jS+NkHMzVroCxzZ3jV7pfFmxpB4mDrB4vPgcZHLFd9nxevnTZEJ OflK1hjqkasUj0d+Qkx2j+zRHS1B29+ETbVaxwsWQ== X-Google-Smtp-Source: AGHT+IGonkt2om5plMmIKXuK+hmkLvsKd+Dr7/njUe+X/mOLfGa1u6WRfmdQYMJUPVz0oRHa8tr8rKScJMGg3fZxKdw= X-Received: by 2002:a92:cda6:0:b0:3e5:4715:ebd4 with SMTP id e9e14a558f8ab-3e55af0ce2amr5804025ab.5.1754934912628; Mon, 11 Aug 2025 10:55:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Mon, 11 Aug 2025 13:54:38 -0400 X-Gm-Features: Ac12FXxIPVAI5tRhEEiebGengSvdbBJbNy22dIoYI_LvQlNKrN83uY-Q4nm6-aE Message-ID: Subject: Re: Adding locks statistics To: Bertrand Drouvot Cc: pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000123b8e063c1aa0fe" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000123b8e063c1aa0fe Content-Type: text/plain; charset="UTF-8" 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 -- Crunchy Data - https://www.crunchydata.com Enterprise Postgres Software Products & Tech Support --000000000000123b8e063c1aa0fe Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Great idea.=C2=A0+1.=C2=A0Here 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 s= ome errant whitespace. Seems to pass pgindent, though.

Name:
I th= ink the name would read better as pg_stat_locks, especially as it returns m= ultiple rows.

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

Code:

+ * Copyright (c) 2021-2025, PostgreS= QL 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, no= t a comment)

-#define PGSTAT_KIND_SLRU 11
-#define PGSTAT_KIND_WA= L 12
+#define PGSTAT_KIND_LOCK 11
+#define PGSTAT_KIND_SLRU 12
+#d= efine PGSTAT_KIND_WAL 13

Why not just add LOCK as #13?

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

--
Enterprise Postgres Software Products & Tec= h Support

--000000000000123b8e063c1aa0fe--