Understanding pg_stat_io.evictions - Mailing list pgsql-general

From Daniel Westermann (DWE)
Subject Understanding pg_stat_io.evictions
Date
Msg-id GV0P278MB0419DB0977CB4FCDE095D0D0D206A@GV0P278MB0419.CHEP278.PROD.OUTLOOK.COM
Whole thread Raw
Responses Re: Understanding pg_stat_io.evictions
List pgsql-general
Hi,

I am trying to understand the evictions statistic in pg_stat_io. I know what evictions are, so this is not the
question.
Given this:

postgres=# select version();
                                           version
----------------------------------------------------------------------------------------------
 PostgreSQL 17devel on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
(1 row)

postgres=# select pg_stat_reset_shared('io');
 pg_stat_reset_shared
----------------------

(1 row)

postgres=# create table t ( a int, b text, c text, d text );
CREATE TABLE

postgres=# insert into t select i,  md5(i::text), md5(i::text), md5(i::text) from generate_series(1,1000000) i;
INSERT 0 1000000

postgres=# select backend_type,evictions,context
             from pg_stat_io
            where backend_type = 'client backend'
              and object ='relation';
  backend_type  | evictions |  context
----------------+-----------+-----------
 client backend |         0 | bulkread
 client backend |         0 | bulkwrite
 client backend |       207 | normal
 client backend |         0 | vacuum

Shouldn't these evictions show up under context blkwrite? The description in docs is:

"Number of times a block has been written out from a shared or local buffer in order to make it available for another
use.

In context normal, this counts the number of times a block was evicted from a buffer and replaced with another block.
Incontexts bulkwrite, bulkread, and vacuum, this counts the number of times a block was evicted from shared buffers in
orderto add the shared buffer to a separate, size-limited ring buffer for use in a bulk I/O operation." 

As far as I understand this, a ring buffer is used in this case. Do I miss something?

Many thanks in advance
Daniel



pgsql-general by date:

Previous
From: Priess Stefan
Date:
Subject: Compile static postgres.lib for postgres 15.3 on Windows
Next
From: Laurenz Albe
Date:
Subject: Re: Reindex after upgrade from PostgreSQL 12.10 to PostgreSQL 15.3