Skip to content

PostgreSQL 17: New catalog view pg_stat_checkpointer

Up to PostgreSQL 16 checkpointer related statistics are available in pg_stat_bgwriter. As the work of bgwriter and checkpointer has been split into two separate processes back in 2011 for PostgreSQL 9.2 (see 806a2aee3791), it makes sense to split the statistics related to those background processes as well. This has now happened for PostgreSQL 17.

Up to PostgreSQL 16 the pg_stat_bgwriter catalog view contains these fields:

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

postgres=# \d pg_stat_bgwriter 
                        View "pg_catalog.pg_stat_bgwriter"
        Column         |           Type           | Collation | Nullable | Default 
-----------------------+--------------------------+-----------+----------+---------
 checkpoints_timed     | bigint                   |           |          | 
 checkpoints_req       | bigint                   |           |          | 
 checkpoint_write_time | double precision         |           |          | 
 checkpoint_sync_time  | double precision         |           |          | 
 buffers_checkpoint    | bigint                   |           |          | 
 buffers_clean         | bigint                   |           |          | 
 maxwritten_clean      | bigint                   |           |          | 
 buffers_backend       | bigint                   |           |          | 
 buffers_backend_fsync | bigint                   |           |          | 
 buffers_alloc         | bigint                   |           |          | 
 stats_reset           | timestamp with time zone |           |          | 

postgres=# 

Starting with PostgreSQL 17 this view looks much simpler and all checkpointer related columns have been removed:

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

postgres=# \d pg_stat_bgwriter 
                      View "pg_catalog.pg_stat_bgwriter"
      Column      |           Type           | Collation | Nullable | Default 
------------------+--------------------------+-----------+----------+---------
 buffers_clean    | bigint                   |           |          | 
 maxwritten_clean | bigint                   |           |          | 
 buffers_alloc    | bigint                   |           |          | 
 stats_reset      | timestamp with time zone |           |          | 

All those columns can now be found in pg_stat_checkpointer:

postgres=# select version();
                              version                               
--------------------------------------------------------------------
 PostgreSQL 17devel on x86_64-linux, compiled by gcc-12.2.0, 64-bit
(1 row)
postgres=# \d pg_stat_checkpointer 
                   View "pg_catalog.pg_stat_checkpointer"
     Column      |           Type           | Collation | Nullable | Default 
-----------------+--------------------------+-----------+----------+---------
 num_timed       | bigint                   |           |          | 
 num_requested   | bigint                   |           |          | 
 write_time      | double precision         |           |          | 
 sync_time       | double precision         |           |          | 
 buffers_written | bigint                   |           |          | 
 stats_reset     | timestamp with time zone |           |          | 

Looks much cleaner like this, one statistic view per process.

Questions about your own setup? A dbi services consultant can look at your case.

Talk to an expert (opens in a new tab)

Let’s work together

Ready to operate at
the next level?

Tell us about your challenge. We’ll bring the depth, the expertise, and the Swiss precision.

Open source Team

Open source Team

Posts published under the Open source Team account are collective contributions by the dbi services open infrastructure consultants. The practice covers open-source databases and platforms, PostgreSQL first of all, along with MySQL, MariaDB, and Linux, from architecture, replication, and high availability to performance tuning and operations under service level agreements, and contributes actively to the PostgreSQL community.View Author posts

721 posts since September 2011

Most read in Database

The Database posts our readers open most: the all-time favourites, and what is trending right now.

2 thoughts on “PostgreSQL 17: New catalog view pg_stat_checkpointer”

  1. Much cleaner 🙂 This view was used for bgwriter tuning :))
    buffers_backend/(buffers_checkpoint + buffers_clean + buffers_backend)

Leave a Comment

Your email address will not be published. Required fields are marked *