From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_buffercache: Add pg_buffercache_os_pages
Date: Mon, 24 Nov 2025 05:29:33 +0000
Message-ID: <E1vNP8n-00172A-0E@gemulon.postgresql.org> (raw)
pg_buffercache: Add pg_buffercache_os_pages
ba2a3c2302f has added a way to check if a buffer is spread across
multiple pages with some NUMA information, via a new view
pg_buffercache_numa that depends on pg_buffercache_numa_pages(), a SQL
function. These can only be queried when support for libnuma exists,
generating an error if not.
However, it can be useful to know how shared buffers and OS pages map
when NUMA is not supported or not available. This commit expands the
capabilities around pg_buffercache_numa:
- pg_buffercache_numa_pages() is refactored as an internal function,
able to optionally process NUMA. Its SQL definition prior to this
commit is still around to ensure backward-compatibility with v1.6.
- A SQL function called pg_buffercache_os_pages() is added, able to work
with or without NUMA.
- The view pg_buffercache_numa is redefined to use
pg_buffercache_os_pages().
- A new view is added, called pg_buffercache_os_pages. This ignores
NUMA for its result processing, for a better efficiency.
The implementation is done so as there is no code duplication between
the NUMA and non-NUMA views/functions, relying on one internal function
that does the job for all of them. The module is bumped to v1.7.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Mircea Cadariu <cadariu.mircea@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/Z/fFA2heH6lpSLlt@ip-10-97-1-34.eu-west-3.compute.internal
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/4b203d499c610160e9867e6add2366780429344c
Modified Files
--------------
contrib/pg_buffercache/Makefile | 2 +-
contrib/pg_buffercache/expected/pg_buffercache.out | 18 ++
contrib/pg_buffercache/meson.build | 1 +
.../pg_buffercache/pg_buffercache--1.6--1.7.sql | 33 ++++
contrib/pg_buffercache/pg_buffercache.control | 2 +-
contrib/pg_buffercache/pg_buffercache_pages.c | 198 +++++++++++++--------
contrib/pg_buffercache/sql/pg_buffercache.sql | 8 +
doc/src/sgml/pgbuffercache.sgml | 108 ++++++++++-
src/tools/pgindent/typedefs.list | 4 +-
9 files changed, 289 insertions(+), 85 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: pg_buffercache: Add pg_buffercache_os_pages
In-Reply-To: <E1vNP8n-00172A-0E@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox