Обсуждение: table names

Поиск
Список
Период
Сортировка

table names

От
"K. Ari Krupnikov"
Дата:
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%';

ari.

Re: table names

От
Brent Verner
Дата:
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

Sorry, I forgot to send a link to the functions described in the
previous reply.

    http://rcfile.org/posthack/pg_stat_du.tar.gz

  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

Re: table names

От
Brent Verner
Дата:
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