Does DROPing a table create a bunch of transactions in the transaction log for all the records being purged?
-
26-02-2021 - |
Frage
If I have a table with billions of records, is it faster and does it create less data in the transaction log to TRUNCATE
it first and then DROP
it or can I just DROP
it all the same?
Lösung
TRUNCATE TABLE and DROP TABLE are both metadata-only operations. They make changes to the system catalog, including which extents are allocated to a particular object. All these changes are logged. But the cost is very small, regardless of the size of the table.
The only thing that will create log records for each row is DELETE.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit dba.stackexchange