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 1ulcCU-003GqC-1I for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Aug 2025 23:45:10 +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 1ulcCS-004Sr4-Fy for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Aug 2025 23:45:08 +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.94.2) (envelope-from ) id 1ulcCR-004Sqw-VI for pgsql-hackers@lists.postgresql.org; Mon, 11 Aug 2025 23:45:08 +0000 Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1ulcCO-0006A6-1W for pgsql-hackers@lists.postgresql.org; Mon, 11 Aug 2025 23:45:07 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 021A41400149; Mon, 11 Aug 2025 19:45:04 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Mon, 11 Aug 2025 19:45:04 -0400 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=1754955903; x=1755042303; bh=ELqA0bYy2J ji7uVxhvhas7Lw0nmcw248Yan4tFrzgzE=; b=O6SXsiYw6r+Ie0okbY4E5IBfpw D4EcqkeRfVEm/LaGy1zCaY87fIzld4vB5FuSRAOH+ZyBwtdX0QI+x7+WE5URqSUW +s7Ovc3xJ4zKX0YhkV3Yb9fnB6haS3XEpOd5J0nPl4dhcW8zb9kcHzSPiS97F23D vBIE4EyKAkbe1aOhslRsiRdKrekT7ewvoynHMVT0vuMu4U9Hxv+HW0ibCramwmlo dojQnzMmZ0E6KvB6ygJIIEzrK3fSwf9E76L1w6NW/FOpGXOlwx6AGXQd6oyNdyG2 ZGwPi2xB4MBlV/gHlyhGFe38x/shobxwru6QT85ymuBAepBYYuBOAgyJKjfw== 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= 1754955903; x=1755042303; bh=ELqA0bYy2Jji7uVxhvhas7Lw0nmcw248Yan 4tFrzgzE=; b=S+EDaGJsmiReyoWYYa9ACoISnsgTXx6GbVwdaH4S4fJXl47D/c/ 6KhMLAKLG9UlpGQf+WN2jbebD6vkMqb+gy+cwfC567HIQOwpqICenUX+qpDtjJPY BSIEW37VbZDk0oM/mrodY9t5aSFU7zudVXPKmUHUFLbvRLMPsp5twnrzQxVztMJm ErVGk0fei3PyCs64U8KtJVSrcp+UC511O95yvHZRoHrS2CRg1wn+A8/Ceyn4StOZ z4G1CBpUreJtOXGLNVIBLuDaDlJVLRriDB/SFw5a5WS807Y17qlzp6sLRDTveEn8 lY/w4q0+32s/ufd5/Op5kcHz7wq63HW7TeQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddufeefkeduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvve fukfhfgggtuggjsehgtderredttddunecuhfhrohhmpefoihgthhgrvghlucfrrghquhhi vghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnh epgfehhefgudefudfgfeelgeeiffegfefhkeefffdvheefuddtheetgeelteevkeetnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrg gvlhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepgedpmhhouggvpehsmhht phhouhhtpdhrtghpthhtohepphhgshhqlhesjhdquggrvhhishdrtghomhdprhgtphhtth hopehhthgrmhhfihgushesghhmrghilhdrtghomhdprhgtphhtthhopegsvghrthhrrghn uggurhhouhhvohhtrdhpghesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqd hhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Aug 2025 19:45:01 -0400 (EDT) Date: Tue, 12 Aug 2025 08:44:58 +0900 From: Michael Paquier To: Jeff Davis Cc: Greg Sabino Mullane , Bertrand Drouvot , pgsql-hackers@lists.postgresql.org Subject: Re: Adding locks statistics Message-ID: References: <87c3170d0645cec732f0d7b2969c75db1b3c86c6.camel@j-davis.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="44fPoQZ1OaD1Z1ow" Content-Disposition: inline In-Reply-To: <87c3170d0645cec732f0d7b2969c75db1b3c86c6.camel@j-davis.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --44fPoQZ1OaD1Z1ow Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 11, 2025 at 02:53:58PM -0700, Jeff Davis wrote: > On Mon, 2025-08-11 at 13:54 -0400, Greg Sabino Mullane wrote: > > Great idea.=A0+1.=A0Here is a quick overall review to get things starte= d. >=20 > Can you describe your use case? I'd like to understand whether this is > useful for users, hackers, or both. This is a DBA feature, so the questions I'd ask myself are basically: - Is there any decision-making where these numbers would help? These decisions would shape in tweaking the configuration of the server or the application to as we move from a "bad" number trend to a "good" number trend. - What would be good numbers? In this case, most likely a threshold reached over a certain period of time. - Would these new stats overlap with similar statistics gathered in the system, creating duplication and bloat in the pgstats for no real gain? Looking at the patch, the data gathered is this, and I don't think that we have metrics gathered in the system to get an idea of the contention in this area, for timeouts and deadlocks: + PgStat_Counter requests; + PgStat_Counter waits; + PgStat_Counter timeouts; + PgStat_Counter deadlock_timeouts; + PgStat_Counter deadlocks; + PgStat_Counter fastpath; Isn't the "deadlock_timeout" one an overlap between timeout and deadlock? Having three counters to track two concepts seems strange to me. Regarding the fastpath locking, you'd want to optimize the fastpath to be close to the number of requests. If you had these numbers, one thing that I could see a DBA do is tune max_locks_per_transaction, which is what influences the per-backend limit of fast-path locks, with FastPathLockGroupsPerBackend. Using static counters for the pending data is going to be necessary when these are called in critical sections, which is I guess why you've done it this way, right? -- Michael --44fPoQZ1OaD1Z1ow Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmiagHoACgkQnvQgOdby QH1dpQ/9H4cjXFaY9cpDqJFvcEGFMrF0cluodAlT06sc5JqmxGfByhDmJebkPMip iEh8JDFrquaKFPCLsaR706Yb0mimVeWHLIx800Bd7fPiUjc+m1Ha67I292ALWuj4 wJRQOEopO+iOoJ/IBkejaW5fZud3XNIx/Z2OZoeLrPzPiBVJCtoVS/nwdYbCAuyh xCeJHQP3IF7EN6EPxzK5fpecwW0vscDR/3iDQqgbLIiiOroF6T4G1nv+CwnT932f GLRhKoXYNOIXaVloM2x0cx1XZDG3LqQiEplT6R2DUUHfaIptT+pPkQV3PbR50+vw 8mr8AcNMJQpH/cLnVd798GaSSxMsg+sRMM5WXbdcCqSs3y8MKs3cDtJ7klfDgGsF /P3mhmf92uM3s3nu7LtoYn4nn5ZONQBRG/Aju+88be5uw+a7f7oPQq8eeIQyEoIe zl8PfpLT+gYtWDyl+lQAiVn1Lj5tTppywpW3WeUDLgvP+bM8HddkKka2DYF2h8RF wg4NZnPRH7xE+izwU90nQYIihNG4HUQY+ejTJXUOqdYWeI80xaIHxl8hZard9RWr dmbVLMy14iyUgFwI6Yj8Y52+8pxsuBorkaGlMEoGij67xotfoi0bHI14CPjs1y9X voU3/e2BDvoSWdOqAjNT2QduXru2OEgei7EABgRSUr67NiiGmzA= =RKBq -----END PGP SIGNATURE----- --44fPoQZ1OaD1Z1ow--