From: | Marcin Krol <mrkafk(at)gmail(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | calculating table sizes + total in one query |
Date: | 2008-11-05 13:07:41 |
Message-ID: | 49119A9D.7020102@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hello everyone,
Some novices may find it useful:
How to calculate disk space occupied by each of top 10 biggest tables:
SELECT relpages * 8192 AS size_in_bytes, relname FROM pg_class WHERE
relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'public')
ORDER BY size_in_bytes DESC LIMIT 10;
How to calculate total disk space occupied by all tables:
SELECT SUM(sizes.size_in_bytes) FROM (SELECT relpages * 8192 AS
size_in_bytes, relname FROM pg_class WHERE relnamespace = (SELECT oid
FROM pg_namespace WHERE nspname = 'public')) AS sizes;
I have two questions:
1. Is it possible to do the equivalent calculations with indexes? If so,
how?
2. Is it possible to display both top 10 tables and the total size of
Regards,
Marcin Krol
From | Date | Subject | |
---|---|---|---|
Next Message | Marcin Krol | 2008-11-05 13:47:47 | VACUUM FULL |
Previous Message | Marcin Krol | 2008-11-05 11:20:05 | viewing currently executing query |