pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add pg_buffercache_evict_{relation,all} functions
Date: Tue, 08 Apr 2025 06:36:24 +0000
Message-ID: <E1u22ZM-003Fe0-0D@gemulon.postgresql.org> (raw)

Add pg_buffercache_evict_{relation,all} functions

In addition to the added functions, the pg_buffercache_evict() function now
shows whether the buffer was flushed.

pg_buffercache_evict_relation(): Evicts all shared buffers in a
relation at once.
pg_buffercache_evict_all(): Evicts all shared buffers at once.

Both functions provide mechanism to evict multiple shared buffers at
once. They are designed to address the inefficiency of repeatedly calling
pg_buffercache_evict() for each individual buffer, which can be time-consuming
when dealing with large shared buffer pools. (e.g., ~477ms vs. ~2576ms for
16GB of fully populated shared buffers).

These functions are intended for developer testing and debugging
purposes and are available to superusers only.

Minimal tests for the new functions are included. Also, there was no test for
pg_buffercache_evict(), test for this added too.

No new extension version is needed, as it was already increased this release
by ba2a3c2302f.

Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Aidar Imamov <a.imamov@postgrespro.ru>
Reviewed-by: Joseph Koshakow <koshy44@gmail.com>
Discussion: https://postgr.es/m/CAN55FZ0h_YoSqqutxV6DES1RW8ig6wcA8CR9rJk358YRMxZFmw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/dcf7e1697ba75ce7883ad7c6bc26ba24422eb892

Modified Files
--------------
contrib/pg_buffercache/expected/pg_buffercache.out |  64 ++++++++
.../pg_buffercache/pg_buffercache--1.5--1.6.sql    |  24 +++
contrib/pg_buffercache/pg_buffercache_pages.c      | 127 ++++++++++++++-
contrib/pg_buffercache/sql/pg_buffercache.sql      |  42 +++++
doc/src/sgml/pgbuffercache.sgml                    |  75 ++++++++-
src/backend/storage/buffer/bufmgr.c                | 175 ++++++++++++++++++---
src/include/storage/bufmgr.h                       |   9 +-
src/test/modules/test_aio/test_aio.c               |   6 +-
8 files changed, 483 insertions(+), 39 deletions(-)



Message-ID: <E1u22ZM-003Fe0-0D@gemulon.postgresql.org>
Permalink:  ../E1u22ZM-003Fe0-0D@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1u22ZM-003Fe0-0D@gemulon.postgresql.org

 · 

reply

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: andres@anarazel.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add pg_buffercache_evict_{relation,all} functions
  In-Reply-To: <E1u22ZM-003Fe0-0D@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