Re: Database size in Postgresql

From: "Peter Koczan" <pjkoczan(at)gmail(dot)com>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: "Kunal Gupta" <kunalgupta(at)live(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Database size in Postgresql
Date: 2008-06-24 19:24:13
Message-ID: 4544e0330806241224n492e1bfarcc96babcd2768969@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Thu, Jun 19, 2008 at 7:18 PM, Joshua D. Drake <jd(at)commandprompt(dot)com> wrote:
> Kunal Gupta wrote:
>>
>> Hi ,
>>
>> I have a question, I am suppose to create database with limited size. Is
>> there any way I can set limit to my database created in postgresql.
>
> Not reasonably no.
>
>> - Since in postgresql (or may be other also), when a database is created,
>> a path to a directory is given in which all data is stored.
>> - If I restrict the size of this directory then by database size will be
>> automatically controlled.
>
> And you might possibly corrupt data when you hit the barrier.

You could always regularly poll the database for the size and generate
a notice or email for you to deal with if it's above a certain
threshold.

postgres=> select pg_database_size('test') as dbsize;
dbsize
-----------
609975524

Or, if you need to do do this in bulk,

postgres=> select datname as database, pg_database_size(datname) as
size from pg_database order by database;

I'm not sure how quickly the size statistics get updated, maybe only
after a VACUUM, but this will work as a reactive policy. There's not a
whole lot you can do to enforce proactive quotas in postgres, and as
Joshua mentioned, you might run into bad things.

Peter

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Bill Bartlett 2008-06-24 21:48:12 Re: PG 8.0.4 - Does Dump + drop_db + reload reset XID to prevent wraparound?
Previous Message Rafael Domiciano 2008-06-24 16:20:05 Re: Functions