Skip to content

Commit c101e59

Browse files
committed
more info in "basic" report
1 parent 4283ef6 commit c101e59

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed

Diff for: general/basic.sql

+33-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
1-
select case when pg_is_in_recovery() then 'Replica' || ' (delay: '
2-
|| ((((case
3-
when pg_last_xlog_receive_location() = pg_last_xlog_replay_location() then 0
4-
else extract (epoch from now() - pg_last_xact_replay_timestamp())
5-
end)::int)::text || ' second')::interval)::text
6-
|| '; paused: ' || pg_is_xlog_replay_paused()::text || ')'
7-
else 'Master'
8-
end as "Node Information";
1+
with data as (
2+
select * from pg_stat_database where datname not in ('postgres', 'template0', 'template1') order by tup_returned desc limit 1
3+
)
4+
select 'Database Name' as metric, datname as value from data
5+
union all
6+
select 'Database Version' as metric, version() as value
7+
union all
8+
select
9+
'Role' as metric,
10+
case
11+
when pg_is_in_recovery() then 'Replica' || ' (delay: '
12+
|| ((((case
13+
when pg_last_xlog_receive_location() = pg_last_xlog_replay_location() then 0
14+
else extract (epoch from now() - pg_last_xact_replay_timestamp())
15+
end)::int)::text || ' second')::interval)::text
16+
|| '; paused: ' || pg_is_xlog_replay_paused()::text || ')'
17+
else 'Master'
18+
end as value
19+
union all
20+
select 'Database Size', (select pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname)) from pg_catalog.pg_database d where pg_catalog.has_database_privilege(d.datname, 'CONNECT') order by pg_catalog.pg_database_size(d.datname) desc limit 1)
21+
union all
22+
select 'Cache Effectiveness', (round(blks_hit * 100::numeric / (blks_hit + blks_read), 2))::text || '%' from data
23+
union all
24+
select 'Successful Commits', (round(xact_commit * 100::numeric / (xact_commit + xact_rollback), 2))::text || '%' from data
25+
union all
26+
select 'Conflicts', conflicts::text from data
27+
union all
28+
select 'Temp Files: total size (total number of files)', (pg_size_pretty(temp_bytes)::text || ' (' || temp_files::text || ')') from data
29+
union all
30+
select 'Deadlocks', deadlocks::text from data
31+
union all
32+
select 'Stat Since', stats_reset::text from data
33+
;

Diff for: start.psql

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
\echo Menu:
2-
\echo ' 1 – Basic Node Information (master/replica, lag, DB size, tmp files)'
3-
\echo ' 2 – '
4-
\echo ' 3 - Slowest Queries'
5-
\echo ' i1 - Unused/Redundant Indexes'
6-
\echo ' i2 - Rarely Used Indexes'
7-
\echo ' q – Quit from this tool'
2+
\echo ' 1 – Basic Node Information (master/replica, lag, DB size, tmp files)'
3+
\echo ' 2 – ....'
4+
\echo ' 3 - Slowest Queries'
5+
\echo ' i1 - Unused/Redundant Indexes'
6+
\echo ' i2 - Rarely Used Indexes'
7+
\echo ' q – Quit from this tool'
88
\echo
99
\echo 'Type your choice and press <Enter>:'
1010
\prompt d_step_unq

0 commit comments

Comments
 (0)