28 lines
804 B
Markdown
28 lines
804 B
Markdown
```sql
|
|
SELECT nspname || '.' || relname AS "relation",
|
|
pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
|
|
FROM pg_class C
|
|
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
|
|
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
|
|
AND C.relkind = 'r'
|
|
ORDER BY pg_total_relation_size(C.oid) DESC;
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```sql
|
|
SELECT schemaname || '.' || relname AS "relation",
|
|
pg_size_pretty(pg_total_relation_size(relid)) AS "total_size",
|
|
pg_size_pretty(pg_table_size(relid) - pg_indexes_size(relid)) AS "table_size",
|
|
pg_size_pretty(pg_indexes_size(relid)) AS "index_size",
|
|
n_dead_tup
|
|
FROM pg_stat_user_tables
|
|
WHERE n_dead_tup > 0
|
|
ORDER BY n_dead_tup DESC;
|
|
```
|
|
|