Monday, June 11, 2012

SharePoint Batch Insert/Update/Delete Performance

When you want to do bulk transaction insert, update, or delete.
If you have to update a larger number of items its highly recommended to not use the Update method on every item. Instead – use the batch update function ProcessBatchData provided by SPWeb.

StringBuilder query = new StringBuilder();
for (int itemIx=0;itemIx<100;itemIx++) {
  query.AppendFormat("" +
          "{1}" +
          "New" +
          "Save" +
          "{2}" +
       "", i, listGuid, someValue, "urn:schemas-microsoft-com:office:office#");
}
SPContext.Current.Web.ProcessBatchData("" +
    "{0}", query.ToString())

For more details of using ProcessBatchData check url:
http://stefan-stanev-sharepoint-blog.blogspot.com/2009/07/tips-for-using-spwebprocessbatchdata.html


No comments: