Hi all,
When we want to get total size of all relation in a schema we have to execute one of our favorite DBA query. It is quite simple but what about displaying schema size when using \dn+ in psql ? gilles=# \dn+ List of schemas Name | Owner | Access privileges | Size | Description --------+----------+----------------------+---------+------------------------ public | postgres | postgres=UC/postgres+| 608 kB | standard public schema | | =UC/postgres | | test | gilles | | 57 MB | empty | gilles | | 0 bytes | (3 rows) The attached simple patch adds this feature. Is there any cons adding this information? The patch tries to be compatible to all PostgreSQL version. Let me know if I have missed something. Best regards, -- Gilles Darold Consultant PostgreSQL http://dalibo.com - http://dalibo.org
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 4da6719ce7..8702e52e4d 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -4188,6 +4188,10 @@ listSchemas(const char *pattern, bool verbose, bool showSystem) { appendPQExpBufferStr(&buf, ",\n "); printACLColumn(&buf, "n.nspacl"); + appendPQExpBuffer(&buf, + ",\n ((SELECT pg_catalog.pg_size_pretty((sum(pg_catalog.pg_relation_size(c.oid)))::bigint) FROM pg_catalog.pg_class c\n LEFT JOIN pg_catalog.pg_namespace s ON s.oid = c.relnamespace WHERE s.nspname = n.nspname)) as \"%s\"", + gettext_noop("Size")); + appendPQExpBuffer(&buf, ",\n pg_catalog.obj_description(n.oid, 'pg_namespace') AS \"%s\"", gettext_noop("Description"));