Skip to content

Commit 2fa2ef6

Browse files
authored
Update postgres_table_object_size.sql
1 parent 488eccd commit 2fa2ef6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

postgres/postgres_table_object_size.sql

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,21 @@ FROM (
2424
FROM (
2525
SELECT
2626
c.oid,
27-
nspname AS table_schema,
28-
relname AS table_name,
27+
n.nspname AS table_schema,
28+
c.relname AS table_name,
2929
c.reltuples AS row_estimate,
30+
pct.relname AS toast_table_name,
3031
pg_total_relation_size(c.oid) AS total_bytes,
3132
pg_indexes_size(c.oid) AS index_bytes,
32-
pg_total_relation_size(reltoastrelid) AS toast_bytes
33+
pg_total_relation_size(c.reltoastrelid) AS toast_bytes
3334
FROM
3435
pg_class c
36+
JOIN pg_class pct ON (c.reltoastrelid = pct.oid)
3537
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
36-
WHERE relkind = 'r'
38+
WHERE c.relkind = 'r'
3739
) a
3840
) a
3941
WHERE table_schema = 'public'
4042
AND table_name like '%'
4143
AND total_bytes > 0
42-
ORDER BY total_bytes DESC;
44+
ORDER BY total_bytes DESC;

0 commit comments

Comments
 (0)