Re: pg_database_size(oid)

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Dhimant Patel <drp4kri(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_database_size(oid)
Date: 2010-02-18 01:46:20
Message-ID: 4B7C9BEC.8080209@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dhimant Patel wrote:
> I have created a database, which I plan to load with several tables. I
> am trying to find the size of the databases and came
> across pg_database_size(oid) function.

Here's what you probably want:

select datname,pg_size_pretty(pg_database_size(pg_database.oid)) from
pg_database order by pg_database_size(pg_database.oid) desc;

The OID in these are sort of hidden column, there's a list of them all
at http://www.postgresql.org/docs/current/static/ddl-system-columns.html

Most tables will not have an OID nowadays, but many of the system
catalog ones still do. ctid is another handy one to know about--useful
for removing duplicate records and some other fancy tricks.

--
Greg Smith 2ndQuadrant US Baltimore, MD
PostgreSQL Training, Services and Support
greg(at)2ndQuadrant(dot)com www.2ndQuadrant.us

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2010-02-18 03:49:56 Re: [GENERAL] possible bug with inheritance?
Previous Message Greg Smith 2010-02-18 01:38:21 Re: tuning bgwriter in 8.4.2