TRUNCATE Question

Started by Alexover 20 years ago3 messagesgeneral
Jump to latest
#1Alex
alex@meerkatsoft.com

Hi,
could anyone tell me if it is necessary to run a Vacuum after truncating
a table or is that done automatically.

Thanks
Alex

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alex (#1)
Re: TRUNCATE Question

Alex <alex@meerkatsoft.com> writes:

could anyone tell me if it is necessary to run a Vacuum after truncating
a table or is that done automatically.

TRUNCATE does not require a vacuum; indeed there's nothing left *to* vacuum.

regards, tom lane

#3Michael Fuhr
mike@fuhr.org
In reply to: Alex (#1)
Re: TRUNCATE Question

On Thu, Nov 10, 2005 at 01:16:24PM +1100, Alex wrote:

could anyone tell me if it is necessary to run a Vacuum after truncating
a table or is that done automatically.

http://www.postgresql.org/docs/8.0/interactive/maintenance.html#VACUUM-FOR-SPACE-RECOVERY

"If you have a table whose contents are deleted on a periodic basis,
consider doing it with TRUNCATE rather than using DELETE followed by
VACUUM. TRUNCATE removes the entire content of the table immediately,
without requiring a subsequent VACUUM or VACUUM FULL to reclaim the
now-unused disk space."

--
Michael Fuhr