Обсуждение: Table size

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

Table size

От
"Shyam Sunder Rai"
Дата:

Hi,

 

How can I calculate a table size in postgres ?

 

Help please..

 

 

Regards,

Shyam Sunder Rai

 

Re: Table size

От
Andreas 'ads' Scherbaum
Дата:
Hello,

On Thu, 14 Jun 2007 18:10:15 +0530 Shyam Sunder Rai wrote:

> How can I calculate a table size in postgres ?

thats in the docu:

Docu -> The SQL Language -> Functions and Operators ->
System Administration Functions

http://www.postgresql.org/docs/8.2/interactive/functions-admin.html


Kind regards

--
                Andreas 'ads' Scherbaum
Failure is not an option. It comes bundled with your Microsoft product.
 (Ferenc Mantfeld)

Re: Table size

От
Michael Fuhr
Дата:
On Thu, Jun 14, 2007 at 06:10:15PM +0530, Shyam Sunder Rai wrote:
> How can I calculate a table size in postgres ?

To find the size of an existing table use pg_relation_size() or
pg_total_relation_size() (8.1 and later; in earlier versions use
the functions in contrib/dbsize).

http://www.postgresql.org/docs/8.2/interactive/functions-admin.html#FUNCTIONS-ADMIN-DBSIZE

Or did you want to estimate the size of a table given the number
and types of its columns and the number of rows?

--
Michael Fuhr

Re: Table size

От
Jim Nasby
Дата:
On Jun 14, 2007, at 8:16 AM, Michael Fuhr wrote:
> On Thu, Jun 14, 2007 at 06:10:15PM +0530, Shyam Sunder Rai wrote:
>> How can I calculate a table size in postgres ?
>
> To find the size of an existing table use pg_relation_size() or
> pg_total_relation_size() (8.1 and later; in earlier versions use
> the functions in contrib/dbsize).

If you don't need an exact size, you can also look at
pg_class.relpages, which is the size of a relation in pages. The
relation_size functions actually read the size off the filesystem,
which seems to be quite a bit slower if you're dealing with more than
a few files.
--
Jim Nasby                                            jim@nasby.net
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)