Skip to content

Commit e558c91

Browse files
committed
Add table size script for postgres
1 parent e762894 commit e558c91

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- Show a list of biggest tables and indices
2+
-- ordered by decreasing size.
3+
-- Runs instantly.
4+
SELECT
5+
schema_name,
6+
relname,
7+
pg_size_pretty(table_size) AS size,
8+
table_size
9+
FROM (
10+
SELECT
11+
pg_catalog.pg_namespace.nspname AS schema_name,
12+
relname,
13+
pg_relation_size(pg_catalog.pg_class.oid) AS table_size
14+
FROM pg_catalog.pg_class
15+
JOIN pg_catalog.pg_namespace ON relnamespace = pg_catalog.pg_namespace.oid
16+
) t
17+
WHERE schema_name = 'public' AND table_size > 0 ORDER BY table_size DESC;

0 commit comments

Comments
 (0)