From bbefa69b3de2cb487290e9b07827b13dc76c0e53 Mon Sep 17 00:00:00 2001 From: Morgan Date: Fri, 15 May 2020 14:52:59 +0200 Subject: [PATCH] calculating schema size in postgresql --- cheat/postgresql.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cheat/postgresql.md b/cheat/postgresql.md index d86e727..3707c41 100644 --- a/cheat/postgresql.md +++ b/cheat/postgresql.md @@ -26,6 +26,11 @@ `\dn` +### Gets the size of a schema +``` +SELECT pg_size_pretty(SUM(pg_total_relation_size(quote_ident(schemaname) || '.' || quote_ident(tablename)))::BIGINT) FROM pg_tables WHERE schemaname = 'schema_name' +``` + ### Return back to shell `\q`