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.96) (envelope-from ) id 1vr0U5-004rqR-1O for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Feb 2026 21:13:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vr0U3-00GF4L-3D for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Feb 2026 21:13:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vr0U3-00GF4C-0v for pgsql-hackers@lists.postgresql.org; Fri, 13 Feb 2026 21:13:51 +0000 Received: from fhigh-a4-smtp.messagingengine.com ([103.168.172.155]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vr0U0-00000000VVc-2o2E for pgsql-hackers@lists.postgresql.org; Fri, 13 Feb 2026 21:13:50 +0000 Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfhigh.phl.internal (Postfix) with ESMTP id 63085140009D; Fri, 13 Feb 2026 16:13:48 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Fri, 13 Feb 2026 16:13:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1771017228; x=1771103628; bh=7bP5T4U1m9 lMT/bwFOALAJaUB9OOjnfzhw0q7gN5Luo=; b=K+Xqd8VPK8aKsxSfQl3394tNE/ A4OIGs+0Xjlr4uQQxPm41Sn74oJqt4D45O0EmVMZgUvIdkWdLRel7e5TLO80+10K VA8WgHysgH/i+SMnmKPnr/oSa1CDGNaiBEzLR+qyCugw/VB2mkDfNWXHMfdkjhq+ EtPmt5yCq1GSLIuPoAm2nxhLtC3oDQJ4KrlAz4ibRKcouKxAiyaaXzjUFEP5WKYz 45/MZ5R2Nn7i3qjEFwUZ4B06DJFKTTXB7P/PmDxBBUBHXoV5dotiLk7cJyVGYILy qAuTcYo6ixZa3woWEqhxoz8wFF7t7RxIX403442wxJ6P4KrwpX4b3dFMVC2Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1771017228; x=1771103628; bh=7bP5T4U1m9lMT/bwFOALAJaUB9OOjnfzhw0 q7gN5Luo=; b=IfYe7jxZW4hswcKXRUr6pFn/g4nmt7kH4z54VPwWPJXrQX4Zi1p //m5QFFFxVGPRNOuHs3l960u4o3b0utnFFcGERubRxFErh+jjrkzO44xstUKgUwY 1jhAXwU+NCmAXeQ4so3N8onIxNbhwnD2u0pNFJbBCan2GgwDs+wKJjkqD1aNGlvB oSHbtMQa/VwOCk/+OK1Bq5E9uI2Zo6mNZedZJSC68kCzmYVkv/0gZP67osHn0ZTs kjV8cT77SPAml9tRFskIGNkSByIkPG3xZlxFQaVWjUktgMM0Bj0qVI+HfiD67EF5 GHjT3XMWwgo7mmlRAZFxdDrQn2rK2BajmPQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvtdelfedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepvdfffeevhfetveffgeeiteefhfdtvdffjeevhfeuteegleduheetveduieet tddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopeehpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopegsvghrthhrrghnuggurhhouhhvohhtrdhpghesgh hmrghilhdrtghomhdprhgtphhtthhopehhthgrmhhfihgushesghhmrghilhdrtghomhdp rhgtphhtthhopehpghhsqhhlsehjqdgurghvihhsrdgtohhmpdhrtghpthhtohepphhgsh hqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghp thhtohepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 13 Feb 2026 16:13:46 -0500 (EST) Date: Fri, 13 Feb 2026 16:13:39 -0500 From: Andres Freund To: Bertrand Drouvot Cc: Michael Paquier , Jeff Davis , Greg Sabino Mullane , pgsql-hackers@lists.postgresql.org Subject: Re: Adding locks statistics Message-ID: References: <87c3170d0645cec732f0d7b2969c75db1b3c86c6.camel@j-davis.com> <1a236172c7dda72939e4293657a90536cce7dd16.camel@j-davis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-02-13 10:24:52 +0000, Bertrand Drouvot wrote: > 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. > > 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. I'm not sure that it's unproblematic to add multiple pgstat count calls to every lock acquisition, particularly if it's a fastpath acquisition or a virtualxid lock. Notably these are external function calls, not just increments of a counter in an inline function. I also don't really know what one would do with some of the information? What does the number of virtualxid lock acquisitions tell you that the numbers of transactions doesn't already tell you in a more understandable way? What does it tell you that the deadlock checker ran N times? It notably doesn't count deadlocks, it counts how often we checked for deadlocks. The percentage of fastpath locks also seems not really informative, because that could be because we ran out of space for fastpath locks, or because a lock mode that's ineligible for fastpath locks was used. What I would actually count is the amount of time waiting for locks, that seems vastly more useful than the number of acquisitions. We already do a GetCurrentTimestamp() inside the timer activations for deadlock timeout, we probably can figure out a way to reuse that to reduce the increase in overhead due to timing. We could also just count the wait time after the deadlock check has run. > @@ -17,6 +17,7 @@ > #include "postmaster/pgarch.h" /* for MAX_XFN_CHARS */ > #include "replication/conflict.h" > #include "replication/worker_internal.h" > +#include "storage/lock.h" > #include "utils/backend_progress.h" /* for backward compatibility */ /* IWYU pragma: export */ > #include "utils/backend_status.h" /* for backward compatibility */ /* IWYU pragma: export */ > #include "utils/pgstat_kind.h" > @@ -342,6 +343,25 @@ typedef struct PgStat_IO > PgStat_BktypeIO stats[BACKEND_NUM_TYPES]; > } PgStat_IO; I don't like the amount of headers this addition will indirectly include in a lot of places. I'm also pretty unhappy about an include of access/transam.h recently having been added. And worker_internal.h quite obviously, given the name, has no business being included here, and also includes a lot more. Grrr. I'll start a thread. Greetings, Andres Freund