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 General > Re: Unloading a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 15443 of 17598
Post > Topic >>

Re: Unloading a table consistently

by craig@[EMAIL PROTECTED] (Craig Ringer) May 4, 2008 at 11:28 PM

Patrick TJ McPhee wrote:

> How about something along the lines of
> 
> BEGIN;
> ALTER TABLE log RENAME to log_old;
> CREATE TABLE log(...);
> COMMIT;
> 
> BEGIN;
> LOCK table log_old;
> COPY log_old TO 'filename-path';
> DROP TABLE log_old;
> COMMIT;
> 
> I believe this will keep the writers writing while keeping the
efficiency
> of truncating.

It's almost a pity that there's no

TRUNCATE TABLE log MOVE DATA TO log_copy;

or similar; ie with two identical table definitions `log' and `log_copy' 
swap the backing file from `log' to `log_copy' before truncating `log'.

`log_copy' could be a new temp table created with CREATE TEM****ARY TABLE 
.... LIKE.

This sort of thing doesn't seem to come up all that much, though.

--
Craig Ringer

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




 6 Posts in Topic:
Unloading a table consistently
xof@[EMAIL PROTECTED] (C  2008-05-03 09:11:16 
Re: Unloading a table consistently
tgl@[EMAIL PROTECTED] (T  2008-05-03 12:56:57 
Re: Unloading a table consistently
xof@[EMAIL PROTECTED] (C  2008-05-03 10:24:36 
Re: Unloading a table consistently
ptjm@[EMAIL PROTECTED] (  2008-05-03 23:29:11 
Re: Unloading a table consistently
craig@[EMAIL PROTECTED]   2008-05-04 23:28:16 
Re: Unloading a table consistently
xof@[EMAIL PROTECTED] (C  2008-05-04 12:07:39 

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 8:31:33 CST 2008.