Hello everyone,
I am creating an application which will migrate about 16k documents and their metadata from a legacy system to SharePoint.
I got the extract of the legacy system in a way that I have a folder containing the document (pdf file) and an xml file with the metadata per document.
I created the whole thing to be able to do the upload and it works fine, but on the other hand it is damned too slow...
I splited the operations, first I upload all the files and then I update the metadata of the files. I also splited the files in batches of 1000 items.
The file uploading takes more time as the list is filled. At the beginning I needed 15 mins for 1000 files, now that the list has already 3000 files in there, it takes about an hour...
I do check if the file already exists before uploading it because I need to report an error if the file was already in the list (duplicates detection)
Is there anyway to improve the performance of the system?
I also have another issue which is the fact my tool to migrate the files is taking more RAM as the list grows. After the 5000th file my tool is using over 1GB of RAM. Could it be because I use a single SPSite instance for the whole upload? Should I recreate it during the upload?
Here is the code I use in order to upload the files:
using (var web = _currentSite.OpenWeb()) { var library = web.GetList(libraryName); var relativeFileUrl = string.Format("{0}/{1}", library.RootFolder, fileName); if (web.GetFile(relativeFileUrl).Exists) throw new InvalidOperationException(string.Format("The file '{0}' already exists", fileName)); var file = web.Files.Add(relativeFileUrl, fileStream, false); }
Thanks a lot for your help!
With kind regards
Carlos