Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

do we need to truncate a large table before dropping?

Tags:

oracle

it is said that we should always truncate a large table before dropping, it improves performance. Is it true?

like image 460
Savitha Avatar asked Dec 16 '22 19:12

Savitha


1 Answers

IMO in general if you simply want to drop a table then DROP is appropriate. It will release space the same way as TRUNCATE would and it will have the advantage of being atomic (no query will have the opportunity to see the table "empty").

From 10g+, a dropped table won't be deleted immediately however: if there is sufficient space it will be put in the recycle bin. If you truncate a table first, no data will remain in the recycle bin. This may be why you have been told to truncate first (?).

In any case, if you want to bypass the recycle bin you could issue DROP TABLE your_table PURGE and this statement will be atomic.

like image 154
Vincent Malgrat Avatar answered Jan 18 '23 22:01

Vincent Malgrat