Re: DELETE versus TRUNCATE during pg_dump.... - Mailing list pgsql-general

From Tom Lane
Subject Re: DELETE versus TRUNCATE during pg_dump....
Date
Msg-id 8201.1103644467@sss.pgh.pa.us
Whole thread Raw
In response to DELETE versus TRUNCATE during pg_dump....  (Patrick Hatcher <pathat@comcast.net>)
Responses Re: DELETE versus TRUNCATE during pg_dump....  (Patrick Hatcher <pathat@comcast.net>)
Re: DELETE versus TRUNCATE during pg_dump....  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Patrick Hatcher <pathat@comcast.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.

            regards, tom lane

pgsql-general by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: RES: RES: NewsForge Poll: Favorite open source database
Next
From: "Vladimir S. Petukhov"
Date:
Subject: Re: Need help to organize database