Re: table names

Поиск
Список
Период
Сортировка
От Brent Verner
Тема Re: table names
Дата
Msg-id 20011117013156.A12103@rcfile.org
обсуждение исходный текст
Ответ на table names  ("K. Ari Krupnikov" <ari@cogsci.ed.ac.uk>)
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Brent Verner
Дата:
Сообщение: Re: table names
Следующее
От: Grant Table
Дата:
Сообщение: Re: Triggers, functions and column names: a poser