Skip Ribbon Commands
Skip to main content

Robin | zevenseas | SharePoint Blog

:

The zevenseas Community > Blogs > Robin | zevenseas | SharePoint Blog > Posts > UpdateListItems vs ProcessBatchData to create Folders
May 11
UpdateListItems vs ProcessBatchData to create Folders

Currently I’m busy in creating huge amounts of folders and I want to have the best performance doing so. So.. I know about the ProcessBatchData method on the SPWeb object that is designed to do ‘batch’ stuff in a very optimized way. Only problem was that I never created folders by using this method.

I thought “hey.. a folder is just a list item with it’s content type set to Folder right?” So by defining the ContentType, the folders were created!! Yeah!! But… SharePoint now was treating this ListItem as a File so it uses the “Name” column instead of the “Title” column to display the Title. So every folder looked like this :

folders_notitle[1]

To fix this I tried the adding following fields :

  • BaseName, generating error “Bad parameter passed to Web Server Extensions.  Check the information you entered and try again”
  • Name, generating error “One or more field types are not installed properly. Go to the list settings page to delete these fields”

in combination with the “urn:schemas-microsoft-com:office:office” schema and without but all the same result.

Here is the xml snippet which I use if you are interested ;)

string methodFormat = "<Method ID=\"{0}\">" +
"<SetList>{1}</SetList>" +
"<SetVar Name=\"ID\">New</SetVar>" +
"<SetVar Name=\"Cmd\">Save</SetVar>" +
"<SetVar Name=\"urn:schemas-microsoft-com:office:office#Title\">{2}</SetVar>" +                
"<SetVar Name=\"urn:schemas-microsoft-com:office:office#ContentType\">Folder</SetVar>" +
"</Method>";

I found the Save Method (RPC) page on MSDN which explains a lot of this mysterious CAML and tried a lot of different things but didn’t get any further. Maybe that was a good thing as well since it states that “This method is deprecated and may not be supported in future releases. Instead, use the following Web service method: UpdateListItems Web service method.” So I went there and to my suprise (and delight) the method also accepts a ‘batch’ string. So by using the following snippet I managed to create all the folders I wanted :

string methodFormatListItem = "<Method ID='{0}' Cmd='New'> " +
"<Field Name='FSObjType'>1</Field>" +
"<Field Name='BaseName'>{1}</Field>" +
"<Field Name='ID'>New</Field></Method>";

Only thing that keeps me worried is ‘ how bad is the performance when using the webservice instead of the ProcessBatchData? ’ By doing a test that creates 100 folders 9 times in a row I came up with the following results table (each number is the time measured in milliseconds) :

ProcessBatchData UpdateListItems
1916 3236
874 963
1058 846
1310 967
682 1042
824 1128
674 1012
721 1424
648 1077


And in a graph it looks like this:

webserviceprocessbatchdata[1]

So actually only the first hit is the most expensive one but after the first one, it becomes quite reasonable in my opinion. Of course the ProcessBatchData is the better performing one but the webservice wasn’t that bad as I thought it would be.

Useful references:

 

Technorati Tags:

Comments

Ian Morrish

I had to do something similar to create a folder for every customer in a CRM system using the Document Workspace web service (create folder method) which worked fine on an existing site.

http://www.wssdemo.com/Blog/archive/2007/12/22/creating-sharepoint-document-library-folders-from-csv-file.aspx
System Account on 12/05/2009 01:09

Robin

Hi Ian,

I also tried that webservice.. but it was way too slow. I think it's compareable with creating folders using the default OM.

There were the numbers for that particular webservice

DWS (CreateFolder)
13783ms
16207ms
23638ms
28186ms
34303ms
40738ms
47844ms
53987ms
59551ms

What was your experiences with that webservice in terms of performance?
System Account on 12/05/2009 02:34

Ian Morrish

I'm glad you ran a test on it as I won't use it again but it was very simple to script. I recall it taking about a second per folder on a clean content DB.
I notice that SharePoint Designer uses owssvr.dll batch mode
<?xml version="1.0" encoding="UTF-8"?>
<ows:Batch OnError="Return" Version="12.0.0.000">
 <Method ID="0,NewList">
  <SetVar Name="Cmd">NewList</SetVar>
  <SetVar Name="ListTemplate">101</SetVar>
  <SetVar Name="Title">New_Folder_Name</SetVar>
  <SetVar Name="FeatureId">00bfea71e7174e80aa17d0c71b360101</SetVar>
  <SetVar Name="RootFolder" />
  <SetVar Name="LangID">1033</SetVar>
 </Method>
</ows:Batch>
System Account on 13/05/2009 01:36
 

 Statistics

 
Views: 5966
Comments: 3
Tags:
Published:1474 Days Ago