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 1vqnjg-000h60-1E for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Feb 2026 07:37:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vqnje-00D0v1-1X for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Feb 2026 07:37:07 +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 1vqnjd-00D0us-25 for pgsql-hackers@lists.postgresql.org; Fri, 13 Feb 2026 07:37:06 +0000 Received: from fout-b7-smtp.messagingengine.com ([202.12.124.150]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vqnjb-00000000PXB-3eMU for pgsql-hackers@lists.postgresql.org; Fri, 13 Feb 2026 07:37:05 +0000 Received: from phl-compute-08.internal (phl-compute-08.internal [10.202.2.48]) by mailfout.stl.internal (Postfix) with ESMTP id 25D9C1D0017E; Fri, 13 Feb 2026 02:37:03 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Fri, 13 Feb 2026 02:37:03 -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=1770968222; x=1771054622; bh=HaCSQGp9OX VSE6Mk+mHkykLtoTMYSCsYARWSXvG0fhw=; b=HhxjNPSncLVVKAsVtYQopNSSVm pmUqEw1zYzJEaLBDS1NQwkgaVdvpezfsP8JnoXKCxNWRdIv+zyud5L8dzAQhydp/ Ms1gnGwWDeTvsAi+A6LqE2Y6tDbKP1lMXzADFsIJW3ybmeDDqAudLLcECO7bWTYU 2iUGUajLwyXKrLiFkObsPBCOCYsvqleJoyCYx1b559RlZ6VFTKjCsVciBz6goaTT 9DWAE62tnfoEXG06hevo340HY4vPMpAbf51Gz7+wcn5t52P66/turZ3IPlwHr1+X YavChRJ9j4I/9clJ6Bop+lyrT51R0S41KPwmKGvawqESEKGVa9c+3xucHrJg== 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= 1770968222; x=1771054622; bh=HaCSQGp9OXVSE6Mk+mHkykLtoTMYSCsYARW SXvG0fhw=; b=eKWAg5uR8MK4ioh0P1X4ER5bKnB8/NPihpcUhZNp3RZeiJuMAf0 HNXOu8eV5Chxau02TQIROaM2kMJ+vNoqO2OtPIQ5vtarc9y2huoqDKr55lD5CM+S ksD1Q/6PjwX+XrkQvZ45QK4EcqOvkPjeEIskv6GpTPRW/FOdfhvTPk0S6KNFE/08 lVxp2so+zaJKds7bXw5jROVeOv2xCu5Ta2AWQMSM8UBg3Mj3KqMqwRWgtbybN5BG YEjU5jaylJzdlpATrxEMdDLvvGBWIi9Gpr1t79iW1SqiHCHLzjQutZJN0kYpV8SF x8FrIulc1yaur+M3MBUHksAs3jFLLjNRDyw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvtdejieeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvve fukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhi vghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnh epteelieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdejnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrg gvlhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepgedpmhhouggvpehsmhht phhouhhtpdhrtghpthhtohepsggvrhhtrhgrnhguughrohhuvhhothdrphhgsehgmhgrih hlrdgtohhmpdhrtghpthhtohepphhgshhqlhesjhdquggrvhhishdrtghomhdprhgtphht thhopehhthgrmhhfihgushesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqd hhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 13 Feb 2026 02:37:01 -0500 (EST) Date: Fri, 13 Feb 2026 16:36:57 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: 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: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Uf9F6Dk18ouFjoBO" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Uf9F6Dk18ouFjoBO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Feb 10, 2026 at 07:30:50AM +0000, Bertrand Drouvot wrote: > New rebase due to 73d60ac385a. I have been looking at this patch, and can get behind the data gathered here in terms of being able to tune things, but not all. See below for the details of my reasoning. max_locks_per_xact is a PGC_POSTMASTER, so backend-level stats with this data would not be relevant for its tuning. However, something else can be said about deadlock_timeout, where one could rely on the data gathered by this view to set it on a backend basis, particularly if the load pattern is divided into a subsets of connections (say few backend see a lot of the deadlock_timeout, for example). Same argument for lock_timeout, which is user-settable. As the set of data gathered, I think that I'm OK with timeouts (for lock_timeout), deadlock_timeouts (for deadlock_timeout), fastpath (for max_locks_per_xact), that can all be compared with the number of requests. Regarding "deadlocks" and "waits", these two are less useful than the three others because not really actionable. They would become much more relevant if and only if we know the distribution of the deadlocks not only for the lock types, but for the objects involved, especially if the activity is diluted across many objects. So these have less value IMO because they are not really actionable in the system. The other three can be directly tuned based on the GUCs we have. 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. Regarding the implementation, you are right to use a fixed-sized stats kind for the job. I can see a lot of code has been copy-pasted from pgstat_io.c, then slightly adjusted to fit into the picture. That's fine here, it makes the implementation straight-forward to read. Regarding the documentation, listing all the values for locktype is a recipe for rot. I'd suggest to remove the list instead, with only a link referring to pg_locks to avoid the duplication. -- Michael --Uf9F6Dk18ouFjoBO Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmmO1JkACgkQnvQgOdby QH2tfQ//b52gcCQLSxDkBTDqVZ0ut29GkvnLEZYbDQyxWhefMClxF0LuCpUnZ39R w/9TuudY5bew/GXFiND9ijqpcdruXWl2Z3YsJwPLQiIYc7Udfz5UpnLrfAkb5DcL NixNTfYDRRC3G9r9PvX8PswkID80TVbqgj66gE1cUb/U4tdtGMyYKrXnrd1u8kFQ QmiBmHdCo1NaZrC8ZAxQVAti6N8KwEXAPbPyY6xUsFJOL0SzdIgf5X5t7lyEw/3j mp7dd2ib4iSkwcQthZiHQdtU5XSlH9BRo9+ASwKRPJUEw6D3eRzMil2lqAiNs2Xf i5lv07buzb/twDyQ0V0K3fOyK1mxT4lzsjsbEkqXC3AlzzZ3gEoCKml/LCrZuZSg qZe4eCiYur3LeJTA4xFKrCu9BflDiHBa7QK1+S2FOTeOtwV1CKD/+R47WIANQEQN WE/RezrahIarpLu7jDiXfBHLJ251G8IfmrONdTIuNilx69gFoOdBfnYvAchY2vDF YNpOn0ZkNPFkBvmVuUXepfzfLgZ6RkMlEdX0Skh5U5n3UpCsHGLAG6dK0PwAfLQk 45zG4qhN1b0ETai1Az8GQBw4tibDFal0XBtXg2EkrQKNkYnnEeTjA/BKYkDbsj61 1FWunAUIbbPH9EkP129va1jolkOPIUQLRoUOv1geoHYxGp/EHiI= =ydx3 -----END PGP SIGNATURE----- --Uf9F6Dk18ouFjoBO--