postgresql/contrib/pg_buffercache
Michael Paquier 4b203d499c pg_buffercache: Add pg_buffercache_os_pages
ba2a3c2302 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
2025-11-24 14:29:15 +09:00
..
expected pg_buffercache: Add pg_buffercache_os_pages 2025-11-24 14:29:15 +09:00
sql pg_buffercache: Add pg_buffercache_os_pages 2025-11-24 14:29:15 +09:00
.gitignore Add regression test coverage for contrib/pg_buffercache. 2022-07-30 15:33:44 -04:00
Makefile pg_buffercache: Add pg_buffercache_os_pages 2025-11-24 14:29:15 +09:00
meson.build pg_buffercache: Add pg_buffercache_os_pages 2025-11-24 14:29:15 +09:00
pg_buffercache--1.0--1.1.sql Add pinning_backends column to the pg_buffercache extension. 2014-08-22 00:28:37 +02:00
pg_buffercache--1.1--1.2.sql Update pg_buffercache extension for parallel query. 2016-06-09 17:18:12 -04:00
pg_buffercache--1.2--1.3.sql Default monitoring roles 2017-03-30 14:18:53 -04:00
pg_buffercache--1.2.sql Update pg_buffercache extension for parallel query. 2016-06-09 17:18:12 -04:00
pg_buffercache--1.3--1.4.sql Add pg_buffercache_usage_counts() to contrib/pg_buffercache. 2023-04-07 14:25:53 -04:00
pg_buffercache--1.4--1.5.sql Add pg_buffercache_evict() function for testing. 2024-04-08 16:23:40 +12:00
pg_buffercache--1.5--1.6.sql pg_buffercache: Change page_num type to bigint 2025-04-08 12:38:42 +02:00
pg_buffercache--1.6--1.7.sql pg_buffercache: Add pg_buffercache_os_pages 2025-11-24 14:29:15 +09:00
pg_buffercache.control pg_buffercache: Add pg_buffercache_os_pages 2025-11-24 14:29:15 +09:00
pg_buffercache_pages.c pg_buffercache: Add pg_buffercache_os_pages 2025-11-24 14:29:15 +09:00