Add sqldu

main
Max Ignatenko 2024-02-23 11:26:06 +00:00
parent ea3e11e495
commit 13b911615d
2 changed files with 18 additions and 0 deletions

View File

@ -48,6 +48,9 @@ init-db:
sqltop:
watch -n 1 'cat top.sql|docker compose exec -i postgres psql -U postgres -d bluesky'
sqldu:
cat du.sql | docker compose exec -iT postgres psql -U postgres -d bluesky
# ---------------------------- Database ----------------------------

15
du.sql 100644
View File

@ -0,0 +1,15 @@
SELECT
relname as table_name,
pg_size_pretty(pg_total_relation_size(relid)) As "Total Size",
pg_size_pretty(pg_indexes_size(relid)) as "Index Size",
pg_size_pretty(pg_table_size(relid)) as "Actual Size"
FROM pg_catalog.pg_statio_user_tables
ORDER BY pg_total_relation_size(relid) DESC;
SELECT
relname as table_name,
indexrelname as index_name,
pg_size_pretty(pg_table_size(indexrelid)) as "Index Size"
FROM pg_catalog.pg_statio_user_indexes
ORDER BY pg_table_size(indexrelid) DESC;