SharePoint: Get better performance when getting list items

Another day, another solved mystery. Developers have interesting lifes as long as there are problems to solve. Another surprise from SharePoint – how to bog server down using only couple of lines of code? Of course, I have solution too that eliminates the issue.

Let’s say you have large document library with many documents (let’s say there is a little bit more than 90.000 documents). Some of them are versioned, some of them are new and so on. Now, let’s say you have to manipulate documents in your code and you have to find document with specific ID. The document, if it exists, is given to you as SPListItem:


SPListItem item = list[new Guid(itemGuidString)];

When you try something like this the code may run fast – as long as you have few documents you don’t have any performance issues. But if you have about 90.000 documents than retrieveing one document as list item may take about 1:00 or 1:30 minutes with no problems. And good server you are using is not saving you this time.

What you have to do is to ask documents by items’s unique ID from SPList.


SPListItem item = list.GetItemByUniqueId(new Guid(itemGuidString));

If you ask documents this way then documents are retrieved through CAML query and you save on performance a lot.


One thought on “SharePoint: Get better performance when getting list items

  • Martin says:

    As SharePoint Server gains popularity and more and more server farm configurations are deployed for a large number of concurrent users, application performance can suffer if the database bottleneck is not properly addressed.

    NCache can help remedy the situation by caching objects and sessions in memory in a highly synchronized manner across multiple servers in a web farm thereby reducing expensive database trips and rendering the SharePoint application highly scalable and lightening fast.

Leave a Reply

Your email address will not be published. Required fields are marked *