Re: pg_stat_statements, write activity

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
Cc: pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_stat_statements, write activity
Date: 2025-05-19 06:57:38
Message-ID: 841006e17c5eeb4536289bd203dc59650e5cce21.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Sat, 2025-05-17 at 08:50 -0600, Scott Ribe wrote:
> > On May 16, 2025, at 1:37 PM, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
> >
> > Sometimes, a backend writes a block to disk itself. This might happen if a lot
> > of cache pressure, but usually it happens when the table is extended with new
> > blocks.
>
> Ah, that's the piece I was missing!
>
> Do the written blocks get counted as dirty first, or only as written?

They will certainly be dirty as well. You can use simple experiments to answer
questions like this:

CREATE TABLE new(id integer);

EXPLAIN (ANALYZE, BUFFERS, COSTS OFF, SUMMARY OFF) INSERT INTO new VALUES (42);

QUERY PLAN
════════════════════════════════════════════════════════════
Insert on new (actual time=0.165..0.166 rows=0.00 loops=1)
Buffers: shared dirtied=1 written=1
-> Result (actual time=0.002..0.003 rows=1.00 loops=1)

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Ribe 2025-05-19 12:34:09 Re: pg_stat_statements, write activity
Previous Message Clay Jackson (cjackson) 2025-05-19 03:28:35 RE: PostgreSQL Load Testing