Re: Use pgBufferUsage for block reporting in analyze - Mailing list pgsql-hackers

From Anthonin Bonnefoy
Subject Re: Use pgBufferUsage for block reporting in analyze
Date
Msg-id CAO6_XqrdfDen3EivTRHQjeijcog9qkoFpr2g28+jZcv7Cxf9EA@mail.gmail.com
Whole thread Raw
In response to Re: Use pgBufferUsage for block reporting in analyze  (Karina Litskevich <litskevichkarina@gmail.com>)
Responses Re: Use pgBufferUsage for block reporting in analyze
List pgsql-hackers
Hi,

Thanks for the review, I've updated the patches with the suggestions:
- moved renaming of misses to reads to the first patch
- added intermediate variables for total blks usage

I've also done some additional tests using the provided
vacuum_analyze_buffer_usage.sql script. It relies on
pg_stat_statements to check the results (only pgss gives information
on dirtied buffers). It gives the following output:

 psql:vacuum_analyze_buffer_usage.sql:21: INFO:  vacuuming
"postgres.pg_temp_7.vacuum_blks_stat_test"
 ...
 buffer usage: 105 hits, 3 reads, 6 dirtied
 ...
              query  | sum_hit | sum_read | sum_dirtied
 --------------------+---------+----------+-------------
  VACUUM (VERBOSE... |     105 |        3 |           6

For vacuum, we have the same results with SKIP_DATABASE_STATS. Without
this setting, we would have block usage generated by
vac_update_datfrozenxid outside of vacuum_rel and therefore not
tracked by the verbose output. For the second test, the second patch
is needed to have ANALYZE (VERBOSE) output the block usage. It will
output the following:

 psql:vacuum_analyze_buffer_usage.sql:29: INFO:  analyzing
"pg_temp_7.vacuum_blks_stat_test"
 ...
 buffer usage: 84 hits, 33 reads, 2 dirtied
 ...
     query            | sum_hit | sum_read | sum_dirtied
 ---------------------+---------+----------+-------------
  ANALYZE (VERBOSE... |      91 |       38 |           2

There's additional buffer hits/reads reported by pgss, those are from
analyze_rel opening the relations in try_relation_open and are not
tracked by the ANALYZE VERBOSE.

Attachment

pgsql-hackers by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: XID formatting and SLRU refactorings (was: Add 64-bit XIDs into PostgreSQL 15)
Next
From: Heikki Linnakangas
Date:
Subject: Re: Interrupts vs signals