linuxpostgresqlpostgresql-9.5pg-stat-statements

Incorrect stats_reset value in pg_stat_bgwriter


I am checking the stats of background process by below command:

select * from pg_stat_bgwriter ;

But after resetting the stats by command:

select pg_stat_reset() ;

I am expecting the column stats_reset return the time at which stats reset, but it shows the very old time. Any idea or guidance on this ?

Example output:

checkpoints_timed | checkpoints_req | checkpoint_write_time | checkpoint_sync_time | buffers_checkpoint | buffers_clean | maxwritten_c lean | buffers_backend | buffers_backend_fsync | buffers_alloc | stats_reset -------------------+-----------------+-----------------------+----------------------+--------------------+---------------+------------- -----+-----------------+-----------------------+---------------+------------------------------- 2525 | 9 | 193751796 | 322501 | 3162662 | 30839 | 176 | 451310 | 0 | 4120735 | 2016-09-27 08:32:43.638545-05

Thanks


Solution

  • Got the answer in the documentation : Doc- link

    bgwriter is the shared among all the databases so it can be reset by different function by the below command:

    pg_stat_reset_shared('bgwriter') ;