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 1vs5iJ-005DSf-0W for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Feb 2026 21:01:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vs5iH-005hzC-0a for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Feb 2026 21:01:01 +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 1vs5iG-005hyz-20 for pgsql-hackers@lists.postgresql.org; Mon, 16 Feb 2026 21:01:01 +0000 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.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 1vs5iD-00000000x37-3xT1 for pgsql-hackers@lists.postgresql.org; Mon, 16 Feb 2026 21:00:59 +0000 Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfhigh.stl.internal (Postfix) with ESMTP id 44CA97A0261; Mon, 16 Feb 2026 16:00:57 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Mon, 16 Feb 2026 16:00:57 -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=1771275657; x=1771362057; bh=+xx5RXQqFd vVZDhK3B2ueUnMqg3qyQGVeBBJhpzqJNU=; b=O9aBE+FYTCxMTTwMjVwmR2Xf8B xMO+GVQScW8wJwLRTRO9nYx2TOgQOqe71f24JMVlVCH5KMkbsq1P++j98QRktFJx X6v85Zv0bGlADBMDBc/vO7ENSNdIJbuU+TWUM1O5sT4e0pczUpU5nUTBPkLNBEQw A6kWfsry4ZhoQTcyZdEiviWQnxWbfODqGHo5CHk7OP382qqL3TrFoV+vdXWLGmFK FsKP/z+mUqRFXy9fobkkVYJdXsPZ5lEP4fdrP8NMtNuFhX6BA5ExxBeT4J+05qA6 ldIqqlPqF6mYIXk71tWD8XelniahmnKF4+o3WZjOb9nXIkQTk+H3cqzjl1pg== 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= 1771275657; x=1771362057; bh=+xx5RXQqFdvVZDhK3B2ueUnMqg3qyQGVeBB JhpzqJNU=; b=oyU4gcDDDArR2kSt9E/6U4nvGHG7Xvd4KyWUafJLEsjvfeJo983 UZzxO3xsnCdxUjH04nffnE3e8N4cb9NHBuffE+NMgK6x+lGiaYR6QTd6++96HavV 1Dj+Kvtq8rVagVyaFl8treIHa65FLOtDMG/Mvy4E0wA8rjHZL0NaoY1gD4ZIWav2 Wi/qUYpHO/AI1DuOTlUIYku2bHMY/gwhvffq2hnBqvW1F8qFfhabpWZJh7o+fS9b fW4xRWeODBsDsgBAgr3oViYjSceOcxhpEz+30KDmtd2h1eKTdeJqdBWxqvLRCOfZ 2E4Ewb9TGJppxMhd9c2nNSe18qq7hMZkGeA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvudejkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtsfdttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepfeffgfelvdffgedtveelgfdtgefghfdvkefggeetieevjeekteduleevjefh ueegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopeehpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopegsvghrthhrrghnuggurhhouhhvohhtrdhpghesgh hmrghilhdrtghomhdprhgtphhtthhopehhthgrmhhfihgushesghhmrghilhdrtghomhdp rhgtphhtthhopehpghhsqhhlsehjqdgurghvihhsrdgtohhmpdhrtghpthhtohepphhgsh hqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghp thhtohepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 16 Feb 2026 16:00:56 -0500 (EST) Date: Mon, 16 Feb 2026 16:00:56 -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: <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-16 10:10:21 +0000, Bertrand Drouvot wrote: > On Fri, Feb 13, 2026 at 04:13:39PM -0500, Andres Freund wrote: > > On 2026-02-13 10:24:52 +0000, Bertrand Drouvot wrote: > > > > > > 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. > > Yeah, we could create inline functions instead. I think unless you have a heck of a lot more of a usecase than "it's information", counting every lock acqusition seems just worth ti. > > 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? > > I agree not that much, except being able to compute a transactions/virtualxid > ratio or such. Also the idea was to report the same as pg_locks so that one > could start sampling pg_locks if he needs more details. I don't think that's worth adding overhead to something extremely frequently happening. > > 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. > > Right, maybe we could add an "exceed fastpath slots" or such counter? That I could get behind. > > 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. > > 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. > 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. I don't think you have provided any actual motivation for why it's worth the expense to track the number of lock requests. Just trackings stats that nobody has a usecase for that are not free to collect makes no sense. Greetings, Andres Freund