How to speed up the deletion of large amounts of list items within SharePoint

Posted by Eric Bartels

If you have code which deletes a lot of items from a SharePoint list (“clear the list”) your best only friend is the ProcessBatchData-Method of the current SPWeb-object.

Recycling will slow you down…

Every item you delete will be stored in the recycle-bin of your site and later in the recycle-bin of your site-collection.

…so simply stop recycling!

To speed up the process even more you should disable the recycle-bin for the time of the deletion-process.

// web is a the SPWeb object your lists belong to
 
// Before starting your deletion
web.Site.WebApplication.RecycleBinEnabled = false;
 
// When your are finished re-enable it
web.Site.WebApplication.RecycleBinEnabled = true;

One Response to “How to speed up the deletion of large amounts of list items within SharePoint”

  1. You should mention that setting RecycleBinEnabled = false; deletes all files in the recyclebin…

Leave a Reply