Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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

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

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.


In response to

pgsql-admin by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group