| From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
|---|---|
| To: | Patrick TJ McPhee <ptjm(at)news-reader-radius(dot)uniserve(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Unloading a table consistently |
| Date: | 2008-05-04 15:28:16 |
| Message-ID: | 481DD610.5010206@postnewspapers.com.au |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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 TEMPORARY TABLE
... LIKE.
This sort of thing doesn't seem to come up all that much, though.
--
Craig Ringer
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Craig Ringer | 2008-05-04 15:50:26 | Re: Custom C function - is palloc broken? |
| Previous Message | Hannes Dorbath | 2008-05-04 15:01:04 | Re: SQL window functions |