Skip to content

Commit 12aefc5

Browse files
committed
2: better total-related % adjustment
1 parent b8b0583 commit 12aefc5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sql/2_table_sizes.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ select
3838
when row_estimate > 10^3 then round(row_estimate::numeric / 10^3::numeric, 0)::text || 'k'
3939
else row_estimate::text
4040
end as rows,
41-
pg_size_pretty(total_bytes) || ' (' || round(200 * total_bytes::numeric / sum(total_bytes) over (), 2)::text || '%)' as "total (% of all)",
42-
pg_size_pretty(table_bytes) || ' (' || round(200 * table_bytes::numeric / sum(table_bytes) over (), 2)::text || '%)' as "table (% of all tables)",
43-
pg_size_pretty(index_bytes) || ' (' || round(200 * index_bytes::numeric / sum(index_bytes) over (), 2)::text || '%)' as "index (% of all indexes)",
44-
pg_size_pretty(toast_bytes) || ' (' || round(200 * toast_bytes::numeric / sum(toast_bytes) over (), 2)::text || '%)' as "toast (% of all toast data)"
41+
pg_size_pretty(total_bytes) || ' (' || round(100 * total_bytes::numeric / sum(total_bytes) over (partition by (schema_name is null)), 2)::text || '%)' as "total (% of all)",
42+
pg_size_pretty(table_bytes) || ' (' || round(100 * table_bytes::numeric / sum(table_bytes) over (partition by (schema_name is null)), 2)::text || '%)' as "table (% of all tables)",
43+
pg_size_pretty(index_bytes) || ' (' || round(100 * index_bytes::numeric / sum(index_bytes) over (partition by (schema_name is null)), 2)::text || '%)' as "index (% of all indexes)",
44+
pg_size_pretty(toast_bytes) || ' (' || round(100 * toast_bytes::numeric / sum(toast_bytes) over (partition by (schema_name is null)), 2)::text || '%)' as "toast (% of all toast data)"
4545
/*,
4646
row_estimate,
4747
total_bytes,

0 commit comments

Comments
 (0)