Skip to content

Instantly share code, notes, and snippets.

@willgarcia
Created July 3, 2014 20:16
Show Gist options
  • Save willgarcia/4e7e1c1388c097218c02 to your computer and use it in GitHub Desktop.
Save willgarcia/4e7e1c1388c097218c02 to your computer and use it in GitHub Desktop.
postgres taille schémas
SELECT schemaname, pg_size_pretty(t.taille::bigint) AS taille_table,pg_size_pretty(t.taille_index::bigint) AS taille_index, pg_size_pretty(t.taille_totale::bigint) AS taille_totale_table
FROM (SELECT schemaname,
sum(pg_relation_size(schemaname || '.' || tablename)) AS taille,
sum(pg_indexes_size(schemaname || '.' || tablename)) AS taille_index,
sum(pg_total_relation_size(schemaname || '.' || tablename)) AS taille_totale
FROM pg_tables
WHERE schemaname != 'my_schema'
GROUP BY schemaname) as t ORDER BY taille_totale DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment