pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Smith <greg@2ndquadrant.com>
To: Kieren Scott <kierenscott@hotmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Restricting schema sizes
Date: Sun, 17 Oct 2010 15:45:16 -0400
Message-ID: <4CBB524C.4030801@2ndquadrant.com> (raw)
In-Reply-To: <BAY149-w53D2CD9EDFAFED3996BF3EAE590@phx.gbl>
References: <BAY149-w53D2CD9EDFAFED3996BF3EAE590@phx.gbl>

Kieren Scott wrote:
> What is the best way to restrict/limit the size that a schema can grow 
> too in Postgresql?
> ...
> The other option I can think of is writing a script that monitors the 
> size of the objects
> within a schema. The danger here is that a user could potentially 
> create a huge table
> as a result of a bad query (cartesian join etc) and fill the 
> application tablespace / filesystem.

You have answered your own question here.  There isn't any facility in 
PostgreSQL yet to enforce disk space usage, so if this requirement is a 
must it's something you'll have to build yourself.  The 
tablespace->filesystem mapping you suggested is probably a good idea to 
house these things at, to prevent one user from taking out the main part 
of the database with something they do.

One way that you can try to limit the damage of rogue queries on top of 
that is to set statement_timeout so they just get cancelled if they run 
for too long.  If the tables are being populated by a single statement 
and you set that to a moderate amount of time, that should be effective 
at cutting off any of the really bad ones after they've run for a 
while.  You'll have to experiment at just how long that timeout should 
be.  If you set log_min_duration_statement (which is a general good idea 
in this situation anyway) and look at what kind of runtime common 
intense but not crippling queries take, that's one way to get feedback 
on where the timeout should be.

-- 
Greg Smith, 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD
PostgreSQL Training, Services and Support  www.2ndQuadrant.us
Author, "PostgreSQL 9.0 High Performance"    Pre-ordering at:
https://www.packtpub.com/postgresql-9-0-high-performance/book

view thread (4+ messages)  latest in thread

Message-ID: <4CBB524C.4030801@2ndquadrant.com>
Permalink:  ../4CBB524C.4030801@2ndquadrant.com/
Also on:    postgresql.org/message-id/4CBB524C.4030801@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: greg@2ndquadrant.com, kierenscott@hotmail.com
  Subject: Re: Restricting schema sizes
  In-Reply-To: <4CBB524C.4030801@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox