Truncate Large Table in SQL Server AG – How to Truncate a Table with 17 Billion Rows in Availability Groups

availability-groupssql servertransaction-logtruncate

I need to truncate a table with 17 billion rows, the table is in a database that is part of an AG.

What will be the effect of this operation on the AG latency and the size of log backups?

Is there a recommended way of doing this?

Best Answer

Truncate table command truncates rows instantly and does not write deleted rows to transaction log file

Usually Truncate table executes instantly and there is no noticeable network traffic between replicas in AG, there will be no noticeable log backups as a consequence, etc., compared to when you do Delete from. However, there can be noticeable traffic and noticeable log backup, because 17 billion rows is a lot.

P.S. Consider backing up the database and save the backup to archive before doing truncate, so you can restore the 17 billion table later, if needed