Refining your custom SharePoint solution’s performance is an important and worthwhile effort. If your application’s lists have a few hundred or less items, then performance may not be an issue. Such low numbers are easy to process and the servers can handle it with ease in most cases. If you have nearly 1,000 lists the application may become sluggish resulting in issues being reported by the users. To avoid a sluggish system, we recommend that you review the code for the following common issues:

1. Not making unnecessary connections to the server.
2. Keeping our data sets clean of extra columns or data we don’t use.
3. Properly closing SPSite and SPWeb.
4. Loops are being handled correctly and are not redundant.
5. Wherever we query SharePoint, we’re using CAML to get our items, not simply using Linq against an item collection.

If the common issues stated above do not improve your system’s performance, we have identified two additional changes that are more involved, but will ensure increased performance.

1. Index fields in the large lists.
Search the application for SPQuery objects, and create a list of all of the fields you search against. You may come up with a list a page long of all of the fields you search in. You then go to each of the lists in SharePoint, within the List Settings you then go to Indexed Columns (under the list of columns). Check off the fields you want and click OK. There is only a limit of 10 fields to include, so choose the fields most commonly used. Click OK. On the larger lists, this will take some time to update.

After going through my application and making this change everywhere, the pages worked properly again. Also, I had noticed that performance had significantly increased.

2. Change the method to create new list items.
I updated all locations when we add list items, from the typical

SPList list = web.Lists[“Name”];
SPListItem newItem = list.Items.Add(); //which calls all items in the list regardless of its size.

to

SPQuery qryEmpty = new SPQuery() { Query = “0” };
SPList list = web.lists[“Name”];
SPListItem newItem = list.GetItems(qryEmpty).Add(); //calls an empty dataset, will return fast

 

For questions or additional SharePoint support, please contact FMT Consultants at(760) 930-6400 or send an email to info@fmtconsultants.com.

 

Written by:
Scott Dowd
Development Practice Manager
FMT Consultants, LLC