Re: pg_database_size(oid) - Mailing list pgsql-general

From Greg Smith
Subject Re: pg_database_size(oid)
Date
Msg-id 4B7C9BEC.8080209@2ndquadrant.com
Whole thread Raw
In response to pg_database_size(oid)  (Dhimant Patel <drp4kri@gmail.com>)
Responses Doubts about oid  (Jayadevan M <Jayadevan.Maymala@ibsplc.com>)
List 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@2ndQuadrant.com   www.2ndQuadrant.us


pgsql-general by date:

Previous
From: Greg Smith
Date:
Subject: Re: tuning bgwriter in 8.4.2
Next
From: Jayadevan M
Date:
Subject: Doubts about oid