@@ -50,25 +50,54 @@ select 'Uptime', (now() - pg_postmaster_start_time())::interval(0)::text
50
50
union all
51
51
select
52
52
' Checkpoints' ,
53
- (select (checkpoints_timed + checkpoints_req)::text from pg_stat_bgwriter)
53
+ (
54
+ case
55
+ when exists (select 1 from information_schema .tables where table_schema = ' pg_catalog' and table_name = ' pg_stat_checkpointer' )
56
+ then (select (num_timed + num_requested)::text from pg_stat_checkpointer)
57
+ else (select (checkpoints_timed + checkpoints_req)::text from pg_stat_bgwriter)
58
+ end
59
+ )
54
60
union all
55
61
select
56
62
' Forced Checkpoints' ,
57
63
(
58
- select round(100 .0 * checkpoints_req::numeric /
59
- (nullif(checkpoints_timed + checkpoints_req, 0 )), 1 )::text || ' %'
60
- from pg_stat_bgwriter
64
+ case
65
+ when exists (select 1 from information_schema .tables where table_schema = ' pg_catalog' and table_name = ' pg_stat_checkpointer' )
66
+ then (
67
+ select round(100 .0 * num_requested::numeric /
68
+ (nullif(num_timed + num_requested, 0 )), 1 )::text || ' %'
69
+ from pg_stat_checkpointer
70
+ )
71
+ else (
72
+ select round(100 .0 * checkpoints_req::numeric /
73
+ (nullif(checkpoints_timed + checkpoints_req, 0 )), 1 )::text || ' %'
74
+ from pg_stat_bgwriter
75
+ )
76
+ end
61
77
)
62
78
union all
63
79
select
64
80
' Checkpoint MB/sec' ,
65
81
(
66
- select round((nullif(buffers_checkpoint::numeric , 0 ) /
67
- ((1024 .0 * 1024 /
68
- (current_setting(' block_size' )::numeric ))
69
- * extract(' epoch' from now() - stats_reset)
70
- ))::numeric , 6 )::text
71
- from pg_stat_bgwriter
82
+ case
83
+ when exists (select 1 from information_schema .tables where table_schema = ' pg_catalog' and table_name = ' pg_stat_checkpointer' )
84
+ then (
85
+ select round((nullif(buffers_written::numeric , 0 ) /
86
+ ((1024 .0 * 1024 /
87
+ (current_setting(' block_size' )::numeric ))
88
+ * extract(' epoch' from now() - stats_reset)
89
+ ))::numeric , 6 )::text
90
+ from pg_stat_checkpointer
91
+ )
92
+ else (
93
+ select round((nullif(buffers_checkpoint::numeric , 0 ) /
94
+ ((1024 .0 * 1024 /
95
+ (current_setting(' block_size' )::numeric ))
96
+ * extract(' epoch' from now() - stats_reset)
97
+ ))::numeric , 6 )::text
98
+ from pg_stat_bgwriter
99
+ )
100
+ end
72
101
)
73
102
union all
74
103
select repeat(' -' , 33 ), repeat(' -' , 88 )
0 commit comments