Re: table names

From: Brent Verner <brent(at)rcfile(dot)org>
To: "K(dot) Ari Krupnikov" <ari(at)cogsci(dot)ed(dot)ac(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: table names
Date: 2001-11-17 06:31:56
Message-ID: 20011117013156.A12103@rcfile.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 16 Nov 2001 at 16:08 (+0000), K. Ari Krupnikov wrote:
| from 7.1 release notes:
|
| > Store tables as files named by OID (Vadim)
|
| until i upgraded to 7.1(.3), i used to track table sizes simply with ls
| -l. is there a simple way to see how much space a table takes on disk,
| short of
|
| select 'ln -s ' || oid || ' ' || relname from pg_class
| where relname not like 'pg%';

I've written some functions to enable:

brent=# SELECT oid, datname, pg_du_db(datname)
brent-# AS diskusage FROM pg_database;
oid | datname | diskusage
--------+-----------+-----------
190550 | brent | 1788
1 | template1 | 1714
16555 | template0 | 1714
(3 rows)

brent=# select relname,pg_du_rel(relname) as diskusage from pg_class
brent-# where (relkind='r' or relkind='i') and relname not like 'pg_%';
relname | diskusage
-------------+-----------
test_id_key | 17
test | 9
(2 rows)

the 'diskusage' is only an approximate value in Kb. The first query
returns diskusage by database name; the second returns diskusage by
relation name (on the current database connection). This is/was
largely done out of needing to track database size (for billing
purposes) -- I know a small shell script could do it, but I felt
like cutting my teeth on a simple c module, so the implementation
is less than perfect...

Tested on 7.1 and 7.2b2 -- no (major) problems encountered.

Read the README.

cheers.
brent

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing." -- Duane Allman

In response to

  • table names at 2001-11-16 16:08:04 from K. Ari Krupnikov

Browse pgsql-general by date

  From Date Subject
Next Message Brent Verner 2001-11-17 06:34:47 Re: table names
Previous Message Bruce Momjian 2001-11-17 05:09:58 Re: TOAST performance (was Re: [GENERAL] Delete Performance)