Database fixed size

Started by Adir Shabanover 9 years ago5 messagesgeneral
Jump to latest
#1Adir Shaban
adirshaban1995@gmail.com

Hey,

Is there anyway to limit a database size?
For example, I need to create a database for user X and I don't want it to
use more than 5 GB.

#2Amul Sul
sulamul@gmail.com
In reply to: Adir Shaban (#1)
Re: Database fixed size

On Wed, Sep 28, 2016 at 1:39 PM, Adir Shaban <adirshaban1995@gmail.com> wrote:

Hey,

Is there anyway to limit a database size?

Nope.
check this /messages/by-id/619537.42270.qm@web53708.mail.re2.yahoo.com
thread.

Regards,
Amul

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Adir Shaban (#1)
Re: Database fixed size

Adir Shaban wrote:

Is there anyway to limit a database size?
For example, I need to create a database for user X and I don't want it to use more than 5 GB.

You can create a tablespace on a device with limited size.
Then you can create the database on that tablespace.

Yours,
Laurenz Albe

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Laurenz Albe (#3)
Re: Database fixed size

Albe Laurenz <laurenz.albe@wien.gv.at> writes:

Adir Shaban wrote:

Is there anyway to limit a database size?
For example, I need to create a database for user X and I don't want it to use more than 5 GB.

You can create a tablespace on a device with limited size.
Then you can create the database on that tablespace.

Note the reference to tablespace. It's unwise to just put the whole
cluster on a tiny device (or equivalently, attempt to solve this with
OS-level disk quotas applied to the whole installation). The reason is
that PG gets very unhappy if it runs out of WAL space. Hitting a limit
on table size per se behaves a bit more sanely, though even there you
can get into trouble --- for instance, in some situations VACUUM will
try to allocate additional disk space, making recovery harder.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#5Adir Shaban
adirshaban1995@gmail.com
In reply to: Tom Lane (#4)
Re: Database fixed size

So how did heroku limit the database size per user?
I thought about creating triggers on insert and updates but that will lead
to bad performance

On Wed, Sep 28, 2016, 15:31 Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Albe Laurenz <laurenz.albe@wien.gv.at> writes:

Adir Shaban wrote:

Is there anyway to limit a database size?
For example, I need to create a database for user X and I don't want it

to use more than 5 GB.

You can create a tablespace on a device with limited size.
Then you can create the database on that tablespace.

Note the reference to tablespace. It's unwise to just put the whole
cluster on a tiny device (or equivalently, attempt to solve this with
OS-level disk quotas applied to the whole installation). The reason is
that PG gets very unhappy if it runs out of WAL space. Hitting a limit
on table size per se behaves a bit more sanely, though even there you
can get into trouble --- for instance, in some situations VACUUM will
try to allocate additional disk space, making recovery harder.

regards, tom lane