So recently at my client site we had a report that was running incredibly long.  This was a while ago, so unfortunately I can’t remember the run time, but I believe it was greater than 12 hours.  The report was pretty basic, just a determination of which documents were created within the month and an output that displayed things like location, file name, created date and creator.

When reviewing the code I noticed the original solution had been coded to loop through each site in the web and then grab all the documents within a particular date range.  The line in particular that scanned the documents was as follows:


[code language=”csharp”]
var listAddedItems = listItems.Where(x => ((DateTime)x["Created"] >= reportManager.ReportStartDate && (DateTime)x["Created"] <= reportManager.ReportEndDate) || ((DateTime)x["Modified"] >= reportManager.ReportStartDate && (DateTime)x["Modified"] <= reportManager.ReportEndDate));

Pretty straight forward, but what it’s actually doing is going through and gathering all the data and throwing out what you don’t need.  Not a big deal unless you are working with a lot of data.  Right now we are sitting at around 1 million items in our SP farm.  I think I found the culprit.

Read more