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 1vrvYi-00DKfX-0d for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Feb 2026 10:10:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vrvYg-001Gij-2D for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Feb 2026 10:10:26 +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 1vrvYg-001GiU-1J for pgsql-hackers@lists.postgresql.org; Mon, 16 Feb 2026 10:10:26 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vrvYd-00000000rxx-3MU3 for pgsql-hackers@lists.postgresql.org; Mon, 16 Feb 2026 10:10:25 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-436e87589e8so3679296f8f.3 for ; Mon, 16 Feb 2026 02:10:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771236623; x=1771841423; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=6A16raj5+CT0Bxf7EjMZfuqjsldkzH6PaRWBjaLnquA=; b=LSqH8p5Jtrenk97UzohtZMRCoW/d81L1oGHkw2AYMR6XzTZdDto2OmWw1C1A/Xwdqh 7sqfOnzatMl70NEE3uoyXtLwtGDQ/qIH2nynmlM5Haj+snd5V6KYNWyuMRSTPKu+1H56 kdNVHMAVgpmNoXZQIZOXTVi9n5bFTrB+0mGiOUKU5CkqSfYiBKLYyO3ODIt47wSCV8jw mBVO6PV13b/Nu4IKoiM2hWOKoPXpVwvtYdV17XBgzY19some7h+BWG4H35vINh0oULEB f/5CGHyizbuHc97u95h2e62MiKDxF5Nc7Ts3/SyqLR3CsyK2stkd7+hUhDzsvt2865gL tnZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771236623; x=1771841423; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6A16raj5+CT0Bxf7EjMZfuqjsldkzH6PaRWBjaLnquA=; b=j8p1qUDzC4xQe6T0mGt18ItwvMFzr/8HeVp0kVaagkZ0foLfwon58KGU5MO0t57xJH A9lTj8yEwr0O7XzVIplZ7k80zqaZy2K4RyiErp/+oYERr0f6dOCwvykWW5iHOhZDcr+6 P3wBvgPAarHKPcvwYOek5+Cf37XGalF3vSeW9mOANMiQyHkvwQeKBHc+CSf1toFvGIjY l/sAKMc+CFM6NT8dMVMXrdJnpqBtvlu0UlwLtkulcyIPsjHxyuEcUyamu8d/WQX99npc mub+Fx9PqDjI3Hm/d0XfKFHtrcmDQ8emq9jM4NTSz+6cWQK7sskDll9rAXeyWn5ctYdB 9xJw== X-Forwarded-Encrypted: i=1; AJvYcCXbSYEGjkapsYTmvC4cJMhMVM0yCsNa1kXJbnCEYvo7lu4JQE/4Orp9V+Z+GFy84stZ3mbnWLY7SOTrNmL8@lists.postgresql.org X-Gm-Message-State: AOJu0Ywr+4tMnr3KrzERo9ikoI8qM8gnCK26+GrZ+LEnlzD+vZ1M2k79 W2sQLzsBGAY5e0S7IdS8ANlLZu/Uo97PRx3Kk+Lqdna/FiupA+2lHttM X-Gm-Gg: AZuq6aJeL33vzRTrBD7Cw9KKut0w1bPpwKnbd/xcYiEmSbUXPFmqhh0L6ftJauBa7vH L30aFEvNQNt/cUTc+90pF39zMOl4GIM+2Daf8dg4G/YEiJ/9hYRkGHc/39DzjoqKL2qoQG3nWIY X2Y4k6H1kw8V2AkA3/DSrOh3FDhOuXrhw6cpXznxoLTtQ/suC3eZd7p6WKpG1JY/Z1LRHhux3j6 cNldIbHekrzRfP0Ix8/ry0NijuAbuH09jXUHr7j5Lhtm1Q8FuWJx+0uWWbXBy7e/hAmZg3fvvJA l9jTndT5N9s31FA35Io2siQBZ+j+9eouPMyalfVYxHrMCI9A7sojlmZkNtCXbOC5Tn3aneZDIip 8PXCQLbsaUYXM/IkZfGHA69vCpT8dfiio83R213KD+T3TApNtXLDwezwmFnWVWOkxzb41xcvbv+ T2bbRY16W0wJlXgNeiXAkldfTTFu7gRXAEhgyyY+YHzT/1SUgGlVWa1bY36/5lgEXxpqGPjLfcK taOgS/qY3B9Tpy7l5FQlUyW+ZRnrugTBr62mQD38Lime+DotsY+LRzH4w== X-Received: by 2002:a05:6000:2905:b0:427:526:16aa with SMTP id ffacd0b85a97d-4379793f5edmr18459917f8f.58.1771236623021; Mon, 16 Feb 2026 02:10:23 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796a6a5e5sm24703859f8f.9.2026.02.16.02.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Feb 2026 02:10:22 -0800 (PST) Date: Mon, 16 Feb 2026 10:10:21 +0000 From: Bertrand Drouvot To: Andres Freund 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 Fri, Feb 13, 2026 at 04:13:39PM -0500, Andres Freund wrote: > Hi, > > 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 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. > 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? > 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? I think that keeping requests would make sense to be able to get the average wait time per request. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com