I have a procedure that empties an auxiliary table and reloads it every time it is invoked. The command used to delete all records is:
DELETE FROM T1;
To my surprise, removing 500.000
records with this command had a cost of approximately 8 segundos
.
After several tests I added the clause WHERE
in the following way:
DELETE FROM T1 WHERE 1=1;
The latter reduced the time considerably to approximately 3 segundos
.
Is there any other, more efficient way to delete all the records in a table?