Skip to content

Commit a74e84b

Browse files
committed
2: more compact table name output
1 parent 3e95496 commit a74e84b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sql/2_table_sizes.sql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
with data as (
44
select
55
c.oid,
6-
nspname as table_schema,
6+
nspname as schema_name,
77
relname as table_name,
88
c.reltuples as row_estimate,
99
pg_total_relation_size(c.oid) as total_bytes,
@@ -15,8 +15,7 @@ with data as (
1515
where relkind = 'r'
1616
)
1717
select
18-
table_schema,
19-
table_name,
18+
coalesce(nullif(schema_name, 'public') || '.', '') || table_name as table,
2019
'~' || case
2120
when row_estimate > 10^12 then round(row_estimate::numeric / 10^12::numeric, 0)::text || 'T'
2221
when row_estimate > 10^9 then round(row_estimate::numeric / 10^9::numeric, 0)::text || 'B'
@@ -32,7 +31,10 @@ select
3231
total_bytes,
3332
table_bytes,
3433
index_bytes,
35-
toast_bytes
34+
toast_bytes,
35+
schema_name,
36+
table_name,
3637
oid
3738
from data
39+
where schema_name <> 'information_schema'
3840
order by total_bytes desc nulls last;

0 commit comments

Comments
 (0)