Created
February 6, 2026 12:13
-
-
Save dcube9/bfe748940ca1180022143b8852352f5b to your computer and use it in GitHub Desktop.
POSTGRESQL - Conta i record e l'occupazione di tutte le tabelle di un database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 1) Aggiorna le statistiche di tutte le tabelle del database corrente | |
| ANALYZE; | |
| -- 2) Leggi le stime aggiornate per tutte le tabelle utente, | |
| -- includendo la dimensione totale (tabella + indici + TOAST) | |
| SELECT | |
| s.schemaname AS schema_name, | |
| s.relname AS table_name, | |
| s.n_live_tup AS row_count_estimated, | |
| pg_total_relation_size(c.oid) AS table_size_bytes, | |
| pg_size_pretty(pg_total_relation_size(c.oid)) AS table_size_human | |
| FROM pg_stat_user_tables AS s | |
| JOIN pg_class AS c | |
| ON c.oid = s.relid | |
| ORDER BY s.schemaname, s.relname; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment