Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: Truncate ta...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 3444 of 3799
Post > Topic >>

Re: Truncate table at a certain size.

by scott.marlowe@[EMAIL PROTECTED] ("Scott Marlowe") Apr 28, 2008 at 09:31 PM

On Mon, Apr 28, 2008 at 7:24 PM, Gurjeet Singh <singh.gurjeet@[EMAIL PROTECTED]
>
wrote:
> On Tue, Apr 29, 2008 at 4:05 AM, Dana Huggard - Navarik
> <dhuggard@[EMAIL PROTECTED]
> wrote:
>
> > Hello,
> >
> > What would be the best method to truncate a table once it reaches a
> > certain size.
> >
> > For instance, a table named log.  I can check the size of the log;
> >
> >   db=# select pg_relation_size('log');
> >   pg_relation_size
> >   ------------------
> >                 8192
> >   (1 row)
> >
> >
> > What I would like to do is
> >
> > If table log, is greater than xxxx bytes
> >   then truncate table log
> >
>
> No, you wouldn't want to do this.... First and foremost, SQL (and
Postgres)
> does not guarantee that the new rows you are inserting land at some
specific
> point in storage; so you can't really be sure which part you want to
> truncate.

I think the OP was talking about running the truncate command on them...

if select pg_relation_size('log') > somesize then truncate log;

If that's the case he can either iterate a list of tables in plpgsql,
an external scripting language, or write some select statement that
creates truncates for all the tables over x size.

something like:

select 'tuncate '||relname||';' from (rest of query from psql -E and
\d here) where pg_relation(relname) > somesize;

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 3 Posts in Topic:
Truncate table at a certain size.
dhuggard@[EMAIL PROTECTED  2008-04-28 15:35:04 
Re: Truncate table at a certain size.
singh.gurjeet@[EMAIL PROT  2008-04-29 06:54:22 
Re: Truncate table at a certain size.
scott.marlowe@[EMAIL PROT  2008-04-28 21:31:17 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 22:28:02 CST 2008.