I am trying to get a greater understanding on the differences between the DELETE and TRUNCATE commands. My understanding of the internals goes something along the lines of:

DELETE -> the database engine finds and removes the row from the relevant data pages and all index pages where the row is entered. Thus, the more indexes the longer the delete takes.

TRUNCATE -> simply removes all the table's data pages en mass making this a more efficient option for deleting the contents of a table.

Assuming the above is correct (please correct me if not):

  1. How do different recovery modes affect each statement? If there is any effect at all
  2. When deleting, are all indexes scanned or only those where the row is? I would assume all indexes are scanned (and not seeked?)
  3. How are the commands replicated? Is the SQL command sent and processed on each subscriber? Or is MSSQL a bit more intelligent than that?

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 dba.stackexchange
scroll top