Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -61,16 +61,21 @@ LIMIT 10;
|
||||
\echo '3. TABLE SIZES (Top 10)'
|
||||
\echo '-----------------------------------------'
|
||||
|
||||
SELECT
|
||||
SELECT
|
||||
s.schemaname,
|
||||
s.relname as tablename,
|
||||
pg_size_pretty(pg_total_relation_size(s.schemaname||'.'||s.relname)) AS total_size,
|
||||
pg_size_pretty(pg_relation_size(s.schemaname||'.'||s.relname)) AS table_size,
|
||||
pg_size_pretty(pg_total_relation_size(s.schemaname||'.'||s.relname) - pg_relation_size(s.schemaname||'.'||s.relname)) AS index_size,
|
||||
s.n_live_tup as row_count
|
||||
FROM pg_stat_user_tables s
|
||||
s.relname AS tablename,
|
||||
pg_size_pretty(pg_total_relation_size(fqname)) AS total_size,
|
||||
pg_size_pretty(pg_relation_size(fqname)) AS table_size,
|
||||
pg_size_pretty(pg_total_relation_size(fqname) - pg_relation_size(fqname)) AS index_size,
|
||||
s.n_live_tup AS row_count
|
||||
FROM (
|
||||
SELECT
|
||||
s.*,
|
||||
quote_ident(s.schemaname) || '.' || quote_ident(s.relname) AS fqname
|
||||
FROM pg_stat_user_tables s
|
||||
) s
|
||||
WHERE s.schemaname IN ('library', 'users', 'authentication', 'displaypreferences', 'activitylog')
|
||||
ORDER BY pg_total_relation_size(s.schemaname||'.'||s.relname) DESC
|
||||
ORDER BY pg_total_relation_size(fqname) DESC
|
||||
LIMIT 10;
|
||||
|
||||
\echo ''
|
||||
@@ -200,8 +205,8 @@ FROM pg_stat_user_indexes
|
||||
WHERE schemaname IN ('library', 'users', 'authentication', 'displaypreferences', 'activitylog')
|
||||
AND idx_scan < 50
|
||||
AND pg_relation_size(indexrelid) > 1000000
|
||||
ORDER BY pg_relation_size(indexrelid) DESC
|
||||
LIMIT 10;
|
||||
ORDER BY tablename, pg_relation_size(indexrelid) DESC;
|
||||
--LIMIT 10;
|
||||
|
||||
\echo ''
|
||||
|
||||
@@ -341,7 +346,7 @@ BEGIN
|
||||
FROM pg_stat_database WHERE datname = 'jellyfin';
|
||||
|
||||
IF hit_ratio < 95 THEN
|
||||
RAISE WARNING 'Low cache hit ratio: %%. Target: >95%%', hit_ratio;
|
||||
RAISE WARNING 'Low cache hit ratio: %. Target: >95%%', hit_ratio;
|
||||
RAISE NOTICE 'RECOMMENDATION: Increase shared_buffers and effective_cache_size';
|
||||
END IF;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user