Re: Size on Disk - Mailing list pgsql-admin

From Oli Sennhauser
Subject Re: Size on Disk
Date
Msg-id 3FC4E582.7080308@bluewin.ch
Whole thread Raw
In response to Re: Size on Disk  (Chester Kustarz <chester@arbor.net>)
List pgsql-admin
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.relnameELSE NULL::name END AS "table", CASE WHEN (class1.relkind = 'r'::"char") THEN NULL::name ELSE
class1.relnameEND 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_indexWHERE ((class1.oid = pg_index.indexrelid) AND (class3.oid = pg_index.indrelid))) IS NOT NULL) THEN (SELECT
class3.relnameFROM 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.sennhauser@bluewin.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


Attachment

pgsql-admin by date:

Previous
From: Jonathan Gardner
Date:
Subject: Re: Compiling --with-openssl on Red Hat 9
Next
From: "Iain"
Date:
Subject: Re: A quick question about domains