| From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> | 
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
| Cc: | Patrick Hatcher <pathat(at)comcast(dot)net>, pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: DELETE versus TRUNCATE during pg_dump.... | 
| Date: | 2004-12-22 16:20:11 | 
| Message-ID: | 20041222162010.GB29278@svana.org | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
On Tue, Dec 21, 2004 at 10:54:27AM -0500, Tom Lane wrote:
> Patrick Hatcher <pathat(at)comcast(dot)net> writes:
> > Curious:  Why would a DELETE FROM tablename work while a pg_dump is 
> > occurring but a TRUNCATE tablename will stay in a lock state until the 
> > pg_dump is complete?
> 
> TRUNCATE requires an exclusive lock on the table.
> 
> This is pretty much a no-free-lunch situation: if you want the pg_dump
> to be able to dump all the rows that existed when it started, you can
> hardly expect to be able to physically remove those rows meanwhile.
I'm wondering though, in principle TRUNCATE could be written to simply
update relfilenode and create a new file and new indexes. Old
transactions will use the old table, new transactions will see an empty
table. I guess the main problem with this would knowing when to delete
the old table (and assocated indexes, etc...).
Basically, it could be equivalent to: DROP TABLE/CREATE TABLE/CREATE
INDEXes... I wonder if the file manager can handle multiple tables with
the same oid?
Have a nice day,
-- 
Martijn van Oosterhout   <kleptog(at)svana(dot)org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Fuhr | 2004-12-22 16:32:55 | Re: valid using INITIALLY DEFERRED | 
| Previous Message | Fernando Schapachnik | 2004-12-22 16:12:32 | Re: Problem with Select output |