Understanding pg_stat_io.evictions

From: "Daniel Westermann (DWE)" <daniel(dot)westermann(at)dbi-services(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Understanding pg_stat_io.evictions
Date: 2023-07-28 10:36:46
Message-ID: GV0P278MB0419DB0977CB4FCDE095D0D0D206A@GV0P278MB0419.CHEP278.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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. In contexts bulkwrite, bulkread, and vacuum, this counts the number of times a block was evicted from shared buffers in order to 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2023-07-28 10:48:37 Re: Reindex after upgrade from PostgreSQL 12.10 to PostgreSQL 15.3
Previous Message Priess Stefan 2023-07-28 10:23:07 Compile static postgres.lib for postgres 15.3 on Windows