Re: Database size in Postgresql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 19, 2008 at 7:18 PM, Joshua D. Drake <jd@xxxxxxxxxxxxxxxxx> 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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux