Skip to content

Commit 7cd6072

Browse files
NikolaySclaude
andcommitted
Remove checkpoint statistics queries to ensure compatibility
- Remove all references to checkpoints_timed, checkpoints_req, buffers_checkpoint - Show informational message directing users to appropriate views - PostgreSQL 17+: Use pg_stat_checkpointer view - PostgreSQL <17: Use pg_stat_bgwriter view - Ensures compatibility without DDL or parsing errors 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 364184a commit 7cd6072

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

sql/0_node.sql

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,13 @@ select 'Started At', pg_postmaster_start_time()::timestamptz(0)::text
4949
union all
5050
select 'Uptime', (now() - pg_postmaster_start_time())::interval(0)::text
5151
union all
52-
select 'Checkpoints Note',
52+
select 'Checkpoint Info',
5353
case
5454
when current_setting('server_version_num')::int >= 170000
5555
then 'Use pg_stat_checkpointer view for checkpoint statistics (PostgreSQL 17+)'
56-
else 'Checkpoint statistics from pg_stat_bgwriter'
56+
else 'Use pg_stat_bgwriter view for checkpoint statistics (PostgreSQL <17)'
5757
end
5858
union all
59-
select 'Checkpoints', (select (checkpoints_timed + checkpoints_req)::text from pg_stat_bgwriter)
60-
where current_setting('server_version_num')::int < 170000
61-
union all
62-
select 'Forced Checkpoints', (
63-
select round(100.0 * checkpoints_req::numeric /
64-
(nullif(checkpoints_timed + checkpoints_req, 0)), 1)::text || '%'
65-
from pg_stat_bgwriter
66-
) where current_setting('server_version_num')::int < 170000
67-
union all
68-
select 'Checkpoint MB/sec', (
69-
select round((nullif(buffers_checkpoint::numeric, 0) /
70-
((1024.0 * 1024 /
71-
(current_setting('block_size')::numeric))
72-
* extract('epoch' from now() - stats_reset)
73-
))::numeric, 6)::text
74-
from pg_stat_bgwriter
75-
) where current_setting('server_version_num')::int < 170000
76-
union all
7759
select repeat('-', 33), repeat('-', 88)
7860
union all
7961
select 'Database Name' as metric, datname as value from data

0 commit comments

Comments
 (0)