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 1vsvJh-008pMK-38 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Feb 2026 04:07:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vsvJg-001iIm-2Y for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Feb 2026 04:07:04 +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.96) (envelope-from ) id 1vsvJg-001iIe-1j for pgsql-hackers@lists.postgresql.org; Thu, 19 Feb 2026 04:07:04 +0000 Received: from fhigh-b6-smtp.messagingengine.com ([202.12.124.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vsvJd-0000000056B-2eNZ for pgsql-hackers@lists.postgresql.org; Thu, 19 Feb 2026 04:07:04 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 5F4717A00F6; Wed, 18 Feb 2026 23:06:59 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Wed, 18 Feb 2026 23:06:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; 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=1771474019; x=1771560419; bh=tl3AZNnXpy +F6pDuj/P9Zqqb9d+FTbokrhnzEw7ot7g=; b=MS+y4yORe5UmhJVScYfBKedW3t 6DqfJYFwZKi2GYqP/78SyqVXtuTHes8Q07/lmKtK6NkpmvQ1EAsebv1nQblJZKe8 eelbTPaMuuQCn7s9Z0LaiV8WqHK93idb7nFppRJ9xkP+XWvp/861thYtiEOkwao5 C9bzcg8J0xYa4xu2HEwNHXyDxAJlcLVU3lzyeJtOWPV/ATclZtqiD3aMh1GCZ5XI 7kkNGNEKflc1DfnlP2ZMJknlcNr6nrQ+LYS1jFPyUz55imQa+pGyzn7wLJvK4OQq vi9abDyV2T4pmANDLM1u9aIXc57NXKzUwYtT4W0346sjL3WDkE6wdPNw0+og== 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= 1771474019; x=1771560419; bh=tl3AZNnXpy+F6pDuj/P9Zqqb9d+FTbokrhn zEw7ot7g=; b=gqtQZo43t61pr0q6VJuFe57nmihubOgu6XD57vLvSY7sqWGvNyS e6AOvPXhwXMOx8RGvGxD1lAOkQxqxryb7n3DcxQKGWXkO1WuD5iTdfio/N8v4AjM 60JjhaAjazbE7d+MxXRSBQ1XI1td76IOTLpeD88T1WLLnGD3cdzWFLq/Iuj2yv5Y TpAyJfCe5LEq35gxbtyy+1qxGQLiLLsrk5Ij2N7OY8DQplU/+keFjIaTzN0PFZ4P HMkdB9++V6dNdpBdBuR3dFo9RAvW0eLDQbO6X/ye2uRiQ/fkzHVWhs26vN+Oyo6q s/BVFBSSxLC44GtKDPltu85usfRJPOlJ5UA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvvdeghedvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeggeeg fffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidp nhgspghrtghpthhtohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsggvrh htrhgrnhguughrohhuvhhothdrphhgsehgmhgrihhlrdgtohhmpdhrtghpthhtoheprghn ughrvghssegrnhgrrhgriigvlhdruggvpdhrtghpthhtohepphhgshhqlhesjhdquggrvh hishdrtghomhdprhgtphhtthhopehhthgrmhhfihgushesghhmrghilhdrtghomhdprhgt phhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlh drohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 18 Feb 2026 23:06:57 -0500 (EST) Date: Thu, 19 Feb 2026 13:06:52 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: Andres Freund , 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: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+jFt4TJQcTD34qRn" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --+jFt4TJQcTD34qRn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 17, 2026 at 04:33:54PM +0000, Bertrand Drouvot wrote: > Okay, done that way in the attached. To avoid overhead due to timing as m= uch as > possible, the patch simply relies on log_lock_waits and deadlock_timeout.= It means > that it relies on the existing code, and increments waits and wait_time o= nly if > log_lock_waits is on and if the session waited longer than deadlock_timeo= ut. >=20 > I did not want to dissociate the waits and wait_time increments so that t= heir > ratio could still make sense. >=20 > That sounds like a good compromise, thoughts? else if (myWaitStatus =3D=3D PROC_WAIT_STATUS_OK) + { + /* Increment the lock statistics counters */ + pgstat_count_lock_waits(locallock->tag.lock.locktag_type); + pgstat_count_lock_wait_time(locallock->tag.lock.locktag_ty= pe, msecs); Not sure that it makes much sense to me to rely on log_lock_waits being enabled to decide if this count and this time are aggregated. The log information and the stats gathering are two separate things. Wouldn't it make more sense to call pgstat_count_lock_waits() outside of this code path, when we know myWaitStatus? While relying on the time calculating for the logs data is a good idea, it seems to me that we should have a separate GUC to enable this number, like a new track_lock_timings? If track_lock_timings or log_lock_waits is enabled, we should calculate the time difference. All these decisions also depends on what deadlock_state holds on top of myWaitStatus, I guess.. -- Michael --+jFt4TJQcTD34qRn Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmmWjFwACgkQnvQgOdby QH26Wg/9GPmgeOlLC1Nni8sAqgMKlOJ2fq3OafSgRCXTZXkiySoaJrKcAakVWdqx /ZDvtGbWJQWc+nuNjQWH/2fvs/4FBbgwy4nPhO+5c0V3215d45eVB2JZTJG9aOKr oRfSzce2msnWWLh3z+LqC5DIJCgZxH5WkT/8SmaxX6N9MQJpTB0z4n4BN6TpF+Oe C7w0VfdoNd1zbtFISVcdUnVoP4bcWW/Nb5BueXSdJ9u/BdDFK3EruILQlPBCFv00 udLdjpbHEwKWEF/PVuLbMZ3AT705zhFq6J9fiBCKI53Gz+AiEPFAcBJWW2mRdfzz L8e/HtscDrVNTBwYzhZa7TbBmgK/JSNQsBRBQKsjsvUJR5maxykyw/Dlwe/YGre6 2LryqVi6GkwtE4SK0lIXK777vF5ER/jPbMDH38zVk8HXMcrFFySYwwtF3u1IFAu1 y8VFeB7lOAXMz/e9EgQnzsIAvADbxOtUBm8rzD3Bo64559Rg/IyP+CGuAOmJFL1f cq7ZAeAwvpT8fA5smm0pVmqfGtoI+ims5M6oNbMkGa6kJ/2nHV9T6P//4nYa5exA ZqgWmV/VRRGNSTpM6MdoqDON1RIbig+d/sk8kak5Tj8hSvKccRtnIj/iEWI6cSDa RjF4BtAs8smLztx5apBsR6KjKON6jiW8CZzQUiVlS6n+xUL7GHM= =99+w -----END PGP SIGNATURE----- --+jFt4TJQcTD34qRn--