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 1wVPvb-001wjQ-11 for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jun 2026 08:29:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wVPva-00B1Qr-0d for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jun 2026 08:29:18 +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 1wVPvZ-00B1Qj-30 for pgsql-hackers@lists.postgresql.org; Fri, 05 Jun 2026 08:29:17 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wVPvY-00000001CuY-0pvn for pgsql-hackers@lists.postgresql.org; Fri, 05 Jun 2026 08:29:17 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-490be29c1c5so20106185e9.2 for ; Fri, 05 Jun 2026 01:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780648155; x=1781252955; 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=Nj4Y2hbgzPDaDmQuBXKErGU3pLeAeClUBRP4CHrxbqI=; b=j6pyOT0a1Sfy0KQJ19FHXUOJocSPec7Rqw1FTf9/ocdRBR+OXnCYmmk1V6umes8jzm xHeAK0xEBosEdnFXK1EAyviZPB6ZX+r7euKIBdsFAtuD0EH8h9p3mz9NEUoL8q1q5uIb sbCbyMZdXRXUhSC1PZm5ocD2tUEJL7SakKXXirtVqQVoBWy/jFQ9gliQsdiC+2lcRdNN fDCtEaae09ru3FvRGpYvpRnwm/LXMdMSv1FbgV06RFVW3lXoL3Iazk7wIq5ZBCpHUdK6 +YBzfs6/Q+ozuYc1b0TMK4xl1FE/qcg4p6Bv4BF3arj+VGC7At8ZJr0c3GydQ0KG8VmY I2ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780648155; x=1781252955; 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=Nj4Y2hbgzPDaDmQuBXKErGU3pLeAeClUBRP4CHrxbqI=; b=T9S5bET6l/WaTsh3O+qHJ9Fi15XfiShV26dcS1tY9ZdarZLHR13d79n+K3G+cCypsb iJfj9ABj/ZaiSAdEY/Z0ca7laWGtNfm5n3BIEr7w1ZGFn+0jGntlNjO6m2XCLLzwjC2a dlvZOfJvJSOhIFdRZyClwMyKCr1ThqvkwYZnN6xUtawz0G+AWt0/4uf/ixE7/8Y7LGLG h5UJorse0yM8HovI5O24B5pKzb5O669+z5h6aQ8fFD7xSloyzlclOMW5WoX6jsQJDqOF aLEJv+m40zS7qP8nesM+YoiBscM/SInFrF+y787FBUjUZHKmDn/a5c0O75vAkZfaZ1EK vKMA== X-Gm-Message-State: AOJu0YzarvBXuBx0/nLah02drafLwJ6tdcwaYXkZAKzqrd1aF8FjMrbc mTDEAGJrk4Ulu020R5hkA+RrAP77wWzl8OxTMvxIxQ5ntOAZnm1paa57 X-Gm-Gg: Acq92OF3hREIYoxA1b31q7brUCIG6B7eIyj+P18JTyoQh/adFLFHQZCEKdLEFbQNGjP VNqXde9Za5EGQ9ty3mwZC1ejBrjIRalV9w5oiy8y7kF+8b18X7kAj8wR2HsgmstD+1SUUfAtWgE 8HEHIHRNT17vlhVCLRO5hsboV556vcY83l+041lnL4f2lCxWsVfyMfFPc/o/WZsxZ2i/akr9gVn jAHYa8H59+tPQxblzrNG/kdo5J8ejbhtiSzQTxjzeQuHHiQVSQjIdP+WlqTVOH0ivjg/bqUQKU5 qtXxpHozh8IFT9QGDOYdokeY66UinUhCUfRmgo+THUlZ8THhm98yIPXIYH43jclunNlKKphYtKw Ph37KvTN/R17DGcscVgJqgTrMZVs07N6FGRS+blWAahcNxu9IhqecK2q35Dg20s2Ao/TZE31pDw 85/rEZlYCRs7Yn6HcGSJGA11auiVM4vYJ7joNSUJ331kLqSeEvjHYTf29C7sg019lBoov2Qk3fV aC+Yn86iUGSTwyUFBYXBTje5Bt1XbDr X-Received: by 2002:a05:600c:8183:b0:488:a882:c7 with SMTP id 5b1f17b1804b1-490c25c6625mr32715725e9.25.1780648154509; Fri, 05 Jun 2026 01:29:14 -0700 (PDT) Received: from bdtpg (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc3a87dasm124214635e9.7.2026.06.05.01.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 01:29:14 -0700 (PDT) Date: Fri, 5 Jun 2026 08:29:12 +0000 From: Bertrand Drouvot To: Tristan Partin Cc: pgsql-hackers Subject: Re: Add per-backend lock statistics Message-ID: References: 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 Thu, Jun 04, 2026 at 09:32:39PM +0000, Tristan Partin wrote: > On Wed Jun 3, 2026 at 1:59 PM UTC, Bertrand Drouvot wrote: > > The motivation makes sense to me. Thanks for looking at it and sharing your thoughts! > > 0001: Refactor pg_stat_get_lock() to use a helper function > > > +static void > > +pg_stat_lock_build_tuples(ReturnSetInfo *rsinfo, > > + PgStat_LockEntry *lock_stats, > > + TimestampTz stat_reset_timestamp) > > I think that the alignment of the second and third arguments could be > off by one. They should line up with the capital R in ReturnSetInfo. They look ok to me in the C file, what about you? > > - values[i] = TimestampTzGetDatum(lock_stats->stat_reset_timestamp); > > + if (stat_reset_timestamp != 0) > > + values[i] = TimestampTzGetDatum(stat_reset_timestamp); > > + else > > + nulls[i] = true; > > It's not super clear to me why this changed in the first patch. It's to make less "noise" in the second patch and keep the second patch focusing only on the "new feature". It's to ease to review but could be merged before being pushed would the commiter decides to do so. > > 0002: Add per-backend lock statistics > > > + Returns lock statistics about the backend with the specified > > + process ID. The output fields are exactly the same as the ones in the > > + pg_stat_lock view. > > It probably makes sense to link to pg_stat_lock here. Not sure as that would not be consistent with pg_stat_get_backend_io and pg_stat_get_backend_wal descriptions in monitoring.sgml. > Other than the few comments I had, this patchset looks good. It follows > patterns that were already established with the per-backend IO and WAL > stats. Thanks! Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com