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 1w5RQE-003FoQ-0C for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2026 16:49:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w5RQC-00FGIE-1g for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2026 16:49:32 +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 1w5RQC-00FGI5-0k for pgsql-hackers@lists.postgresql.org; Wed, 25 Mar 2026 16:49:32 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w5RQ9-000000016L0-41iO for pgsql-hackers@lists.postgresql.org; Wed, 25 Mar 2026 16:49:32 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5a299cba953so160969e87.2 for ; Wed, 25 Mar 2026 09:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774457369; cv=none; d=google.com; s=arc-20240605; b=IqrQFp3mCNRTnIQFC1A51VOMx3tNtokxDrf8jQwW+LdFAYy6ekSZpyJMcBa54idQ5P z/ttsLhc4OytsBtjEkwVoBuwvmo4LYz/rEh04njOGcJa6JZZWIFmkGJpesJ+8eWsUnzk Eg3LWQWzQOqZTDMN2RnzZ88DUYFUp8o6/6GkcpfabCso9sCkSMPUbmVCAOByf80DiGfH OzVgY90PF7sx80/mLnzM3arR/W1cFYq9YfxV9f66B85l3XCceo7IKsBQJGh3hZJHOAmt Aru++v1l2iytEfJKwaVbfuXCOTdUFK9Tk9gkt47vbBy89EZ50tkMUsiIqWdtNiqoPHA/ IMlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=X8OL7sDli5eZJ0vSZewmsCppze8SsBiXDtv5851/QzE=; fh=Iz2D3bCQkvpkOPO4j2/RN4Ugrv1hhM05b4kP1QxDzgs=; b=lGriSDQIXuEwUrRAQVTD4a+46qqZYnjMx+jsdd7LWenqLjV39MiKrAWDb4FaiBqAsh jnFwSPqwgBYl6S++7yeVSRXEPtttxA2cXqsrqBmFyyW4+Yv9CwJYQjESgzhCJ529X2HG yTtA0xdFGE4mMqb1etVDecSGTINohRs8AlNUOUf5AMQVBDuCizQo++vHsi/H5TFwuLxh nh1d5CmQ6uZ2xEpHEwAP07AclN7eM7EChqBt7ehPaR9rCCvUzV/kBzz1gvpirxZ1WqkR PyAlsYgyNRqmNR7z2Ein5xSdNh0kgIcs2T0g3H2ZY+hGoM67OZqcWrPpnbqfwqiYpe62 ksBg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774457369; x=1775062169; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=X8OL7sDli5eZJ0vSZewmsCppze8SsBiXDtv5851/QzE=; b=M9UybhNilt+NaUCps/aUXejAd9jHbSmT503P7qioWCZ3r0WFtdoAnePOFpYaPbk33B cy0RO2TUoJMpCBhh3irlY/enZS8YQ3W6oETtg4lqJmBnriWx4HLxPZOUX3WFfvlBLLZ7 UxKcGQ8vGwdQ5FRezp3z2n5uyrTIUDHap+DutMBOrVypBebRyOarFtuLRavMsAipYrAC MsrDcrtoThpsakixnipQf/iuILU2m8FhAWks5C2C25KXm+xGjKkTMeJjIfz2wT1uAaSc JrSggnk0RGR/CEMCYYUSWm2PGCbiurvC7NI/Dwe+FRXzG39KeoT3boW0KKKpmghOt6mq 16CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774457369; x=1775062169; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=X8OL7sDli5eZJ0vSZewmsCppze8SsBiXDtv5851/QzE=; b=c6jj4HcJuvTOz6dr+I+RnVbmtAR+iQYKytCmLkGbXaWOGF0T78g0gYO40JI+yND2yp 0NBsZo1OGa4Txwh6Aj+qajnDWaSMvjhcXfSP4cfX9o492XcluWO34Ss9/3E5lRUhI13Y 35g2MrPFEBG1a2NtzZv54iZ7x4VxFjroFhQHEPlW1KhTV/LC6am5vKA3asJ4BLLe/1LF fw5gzyB7K5BjuDDz/ikTw42BiVz9c7JmxOImTCfZ0Zx+cWpUN9M+qCdDuO9efYdfrwji 4y3d4/XEjt0nFcBsF8oVgZ/U66KKB6BSRr51m2Zz4RKjYpQK+M1Hq3hfQTaPIl087Wto UjhA== X-Forwarded-Encrypted: i=1; AJvYcCXmvizVAS28KWf9ZaFwyOKYBh8kvTFWz/dEkdV2fDd/nGIxcAb9vYCmgRjlDWDmv6Ns3v7ejOww+MNHFUiU@lists.postgresql.org X-Gm-Message-State: AOJu0YxbTSArOuzHXpij18xIR9a5s8ifYC6oa6V64UxcUeVMKphVe40l 7BRYXRnx0u9z+7KBJdKfyy0v/nkr6XT7r6zb4eNz+F6DgqVncpTu6ojAnAteSGXaKigDCFzoc0m nCuRTgGOyCyNwdcJgTtYGT2iy+rxxRTA= X-Gm-Gg: ATEYQzzCvzRIdsAhu+peBzzYrtedwUNpbstVoyp1rKN39fQo+gUcK5oNUZMgM9I/zAc MbfqEq3eGNW+3gdNoXjaiIGnNL5w+7w6VB/RHtgyY2OOb/L44v/2zywKE7Cb9rSovF8YOqLdBxA bj+8dNAqndFhyufTa/X0eZwwc9XsFZYrzRIfTmVLhTg/Rrz5GHBaq3dhCmes0umCb0uf6BvXLxx TYeTHzUgVR2iw44tr8o/y096eeano5K/JSomSAJ1Ev1raMyDuMhM81EQXvSThspK044RAfRN8dA r7R6bBAg X-Received: by 2002:a05:6512:1317:b0:59e:465c:3b1e with SMTP id 2adb3069b0e04-5a29b99fe64mr2057790e87.41.1774457368726; Wed, 25 Mar 2026 09:49:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Wed, 25 Mar 2026 09:48:52 -0700 X-Gm-Features: AQROBzA0I20goOyKCJKDRQ2t_l711B_wH80T-x7bLLKBQ1d1f0zaDqunsXfOn-E Message-ID: Subject: Re: pg_buffercache: Add per-relation summary stats To: Lukas Fittl Cc: Ashutosh Bapat , PostgreSQL Hackers , Paul A Jungwirth , Khoa Nguyen Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 24, 2026 at 11:47=E2=80=AFPM Lukas Fittl wrot= e: > > Hi Ashutosh, > > On Tue, Mar 24, 2026 at 11:24=E2=80=AFPM Ashutosh Bapat > wrote: > > I know we already have a couple of hand-aggregation functions but I am > > hesitant to add more of these. Question is where do we stop? For > > example, the current function is useless if someone wants to find the > > parts of a relation which are hot since it doesn't include page > > numbers. Do we write another function for the same? Or we add page > > numbers to this function and then there's hardly any aggregation > > happening. What if somebody wanted to perform an aggregation more > > complex than just count() like average number of buffers per relation > > or distribution of relation buffers in the cache, do they write > > separate functions? > > I think the problem this solves for, which is a very common question I > hear from end users, is "how much of this table/index is in cache" and > "was our query slow because the cache contents changed?". > > It can't provide a perfect answer to all questions regarding what's in > the cache (i.e. it won't tell you which part of the table is cached), > but its in line with other statistics we do already provide in > pg_stat_user_tables etc., which are all aggregate counts, not further > breakdowns. > > Its also a reasonable compromise on providing something usable that > can be shown on dashboards, as I've seen in collecting this > information using the existing methods from small production systems > in practice over the last ~1.5 years. Regarding the proposed statistics, I find them reasonably useful for many users. I'm not sure we need to draw a strict line on what belongs in the module. If a proposed function does exactly what most pg_buffercache users want or are already writing themselves, that is good enough motivation to include it. I think pg_visibility is a good precedent here. In that module, we have both pg_visibility_map() and pg_visibility_map_summary(), even though we can retrieve the exact same results as the latter by simply using the former: select sum(all_visible::int), sum(all_frozen::int) from pg_visibility_map('test') ; Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com