By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,613 Members | 1,890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,613 IT Pros & Developers. It's quick & easy.

limit database size

exoskeleton
100+
P: 104
hi dear experts, i would like to know on how to limit the size the postgre database (ex. 10MB per database)? is there any configuration needed in phpadmin or in the php code?

pls help me dear experts...thank you
Jan 24 '07 #1
Share this Question
Share on Google+
7 Replies


Expert 100+
P: 534
You cannot limit the size of the database - there's no such configuration parameter in PostgreSQL.
(And I suspect the reason is that most people never need it)

I suppose you can implement your own control, for example you can have a cron job that would check the size of database (using psql could be the easiest approach) and then do something, (shut down the server?) if database size exceeds some limit.

Expand|Select|Wrap|Line Numbers
  1.  
  2. select pg_database_size('dbname') ;
  3.  
Jan 24 '07 #2

exoskeleton
100+
P: 104
thank you sir but i dont have any idea where to put that code...should i include it in a php file so everytime the client add a record and he reach his limit...the system will tell him that he cant process the transaction anymore because he already reach the limit.

is that it? only that code sir, just one line of code? please help any detailed coding ... please
Jan 25 '07 #3

exoskeleton
100+
P: 104
You cannot limit the size of the database - there's no such configuration parameter in PostgreSQL.
(And I suspect the reason is that most people never need it)

I suppose you can implement your own control, for example you can have a cron job that would check the size of database (using psql could be the easiest approach) and then do something, (shut down the server?) if database size exceeds some limit.

Expand|Select|Wrap|Line Numbers
  1.  
  2. select pg_database_size('dbname') ;
  3.  
sir after this:

select pg_database_size('dbname') ;
...
...
..
..
..

any code after that please...i know that this is exactly what im looking for. of course pg_connect is still needed right before the select statement above...
Jan 25 '07 #4

Expert 100+
P: 534
What to code next depends on which action you want to take.
Your options may vary from sending a warning email to the user to dropping the database.
I would try to avoid any drastic actions, which is hard to justify
(even if you deal with students who use a school server for their classes)
You can also establish a threshold and an action it entails; say if db size exceed 10mb you generate an email, but if it exceeds 100mb you also drop the database.

By the way, what type of authentication users have on this server, is it password, trust, anything else?
Jan 25 '07 #5

P: 7
hi dear experts, i would like to know on how to limit the size the postgre database (ex. 10MB per database)? is there any configuration needed in phpadmin or in the php code?

pls help me dear experts...thank you
I can think of a number of ways to do this. The easiest is to us the tablespaces feature and stick each DB in it's own tablespace on a 10MB partition.
Jan 29 '07 #6

Expert 100+
P: 534
If I understand correctly this approach involves management outside of database (creating a per-user disk partitions)
Also hard limits may be dangerous; unless the out-of-disk-space condition is now nadled better in the latest versions of Postgres running ot of space in the middle of transaction may corrupt the database.
Jan 30 '07 #7

P: 1
In my opinion, the best option is this:
-every user gets a seperate db
-check the size of the databases in e.g. every 5 minutes.
-if the size of a db is larger then the user quota then take away the user's INSERT and CREATE permission. And store somewhere that this happened, then notify the user.
-If at the next check, the db size is under the quota, then give back the permissions.
Aug 20 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.