Re: Size on Disk

From: Oli Sennhauser <oli(dot)sennhauser(at)bluewin(dot)ch>
To: Chester Kustarz <chester(at)arbor(dot)net>
Cc: Grzegorz Dostatni <dostatnig(at)yahoo(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Size on Disk
Date: 2003-11-26 17:40:18
Message-ID: 3FC4E582.7080308@bluewin.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-docs pgsql-hackers

Hello

>SELECT CASE WHEN ((SELECT class3.relname FROM pg_class class3, pg_index WHERE ((class1.oid = pg_index.indexrelid) AND (class3.oid = pg_index.indrelid))) IS NOT NULL) THEN (SELECT class3.relname FROM pg_class class3, pg_index WHERE ((class1.oid = pg_index.indexrelid) AND (class3.oid = pg_index.indrelid))) WHEN (class1.relname IS NOT NULL) THEN class1.relname ELSE NULL::name END AS "table", CASE WHEN (class1.relkind = 'r'::"char") THEN NULL::name ELSE class1.relname END AS "index", (class1.relpages * 8) AS "size (KBytes)" FROM pg_class class1 WHERE ((class1.relkind = 'r'::"char") OR (class1.relkind = 'i'::"char")) ORDER BY CASE WHEN ((SELECT class3.relname FROM pg_class class3, pg_index WHERE ((class1.oid = pg_index.indexrelid) AND (class3.oid = pg_index.indrelid))) IS NOT NULL) THEN (SELECT class3.relname FROM pg_class class3, pg_index WHERE ((class1.oid = pg_index.indexrelid) AND (class3.oid = pg_index.indrelid))) WHEN (class1.relname IS NOT NULL) THEN class1.relname ELSE NULL::name END, CASE WHEN (class1.relkind = 'r'::"char") THEN NULL::name ELSE class1.relname END, (class1.relpages * 8);
>
>
I was verry interested in your querry but I did not understood it.
Therefore I rewrote it. Now it is a little simpler to read and does (in
my opinion) the same?

--
-- Amount of space per object used after vacuum
--
VACUUM;
SELECT c1.relname AS "tablename", c2.relname AS "indexname",
c2.relpages * 8 AS "size_kb", c2.relfilenode AS "filename"
FROM pg_class c1, pg_class c2, pg_index i
WHERE c1.oid = i.indrelid
AND i.indexrelid = c2.oid
UNION
SELECT relname, NULL, relpages * 8, relfilenode
FROM pg_class
WHERE relkind = 'r'
ORDER BY tablename, indexname DESC, size_kb;

Caution: This Sktipt does NOT exactly the same... but the results should
be the same

Regrards
Oli

-------------------------------------------------------

Oli Sennhauser
Database-Engineer (Oracle & PostgreSQL)
Rebenweg 6
CH - 8610 Uster / Switzerland

Phone (+41) 1 940 24 82 or Mobile (+41) 79 450 49 14
e-Mail oli(dot)sennhauser(at)bluewin(dot)ch
Website http://mypage.bluewin.ch/shinguz/PostgreSQL/

Secure (signed/encrypted) e-Mail with a Free Personal SwissSign ID: http://www.swisssign.ch

Import the SwissSign Root Certificate: http://swisssign.net/cgi-bin/trust/import

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message nobody 2003-11-26 17:52:12 Re: Vacuum stats interpreted?
Previous Message Jonathan Gardner 2003-11-26 16:53:19 Re: Compiling --with-openssl on Red Hat 9

Browse pgsql-docs by date

  From Date Subject
Next Message Michal Zaborowski 2003-11-26 22:58:46 Re: Size on Disk
Previous Message Tom Lane 2003-11-26 05:53:27 Re: Size on Disk

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Pflug 2003-11-26 17:43:19 Re: pg_restore and create FK without verification check
Previous Message Greg Stark 2003-11-26 17:40:08 Optimizer cost calculation