From: | Sean Davis <sdavis2(at)mail(dot)nih(dot)gov> |
---|---|
To: | Machiel Richards <machielr(at)rdc(dot)co(dot)za> |
Cc: | "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Calculating database sizes using a script |
Date: | 2010-03-23 09:50:40 |
Message-ID: | 264855a01003230250t77af4cf9ibcdd7c5190cc823c@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Tue, Mar 23, 2010 at 5:08 AM, Machiel Richards <machielr(at)rdc(dot)co(dot)za> wrote:
> Hi all
>
>
>
> I have a client that is running a total of 190 Postgresql databases.
>
>
>
> I am busy with an audit on the database sizes, performance
> tuning,etc...
>
>
>
> However to check the database sizes is quite tedious as some
> of the servers are running up to 24 databases on one instance.
>
>
>
> Due to security restrictions I am not yet able to use
> pgadmin / pgphpadmin and need to manually calculate this using ‘SELECT
> pg_size_pretty(pg_database_size(''));’
>
>
>
>
>
> Is there a way of running this in a script for each database
> in the instance without having to manually type in each database name?
>
>
>
> For instance. Let the script extract the database names and
> then check the sizes printing it to an output file / screen?
A one-liner shell script is pretty straightforward. You could use
your scripting language of choice, besides the shell, if you like:
for i in `psql -t -c "select datname from pg_catalog.pg_database d"`;
do echo $i; psql -t -c "select
pg_size_pretty(pg_database_size('$i'))"; done
Hope that helps.
Sean
From | Date | Subject | |
---|---|---|---|
Next Message | Little, Douglas | 2010-03-23 14:30:55 | Re: string functions and operators |
Previous Message | Machiel Richards | 2010-03-23 09:08:46 | Calculating database sizes using a script |