An Avanade Blogging Community

Welcome to An Avanade Blogging Community Sign in | Join | Help
in Search

MOSS 2007 articles

How to tune your SharePoint custom code

Tired of waisting expensive CPU cycles? Waiting for ages for your site to load? Continue reading!

Sharepoint can be a great platform for starting custom development. The SharePoint API puts us (almost) completely in control. However, beautiull on the outside, it is hardly ever transparent for what is happening on the insde.

During my latest project we faced mutiple issues regarding performance optimization. This article will take a look at some of the interesting and gives a workaround.

Suppose we would want to build a custom navigation menu. To give us a complete collection of all available SPWeb´s, perfectly suited for our navigation class, we like to use the function SPSite.Allwebs().

Now here is an unharmful SharePoint call. Or isn´t it...?

Though it performed nicely on our testing environment, we encountered huge performance issues on production. The thing is, the more webs a site has, the longer the call will take. When dealing with around 300 SPWeb´s, each page load would start to take ages (well it might have been seconds, but the server CPU was at full blast).

To avoid this, I´d suggest caching. Preferably (but optional) using the Microsft Enterprise Library. Loop thru the SPWeb collection, copy all the information required into a DataTable object, and place that into the cache. Finally, just add some code to see if you have the DataTable in cache, and if so, skip the expensive AllWebs call.

Enjoy the new record load times. Your visitors wil get so excited they´d wanna hug you and squeeze you.

 

Published Wednesday, May 30, 2007 1:59 PM by Wilko Wissingh
Filed Under:

Comments

No Comments
Anonymous comments are disabled

This Blog

Post Calendar

<May 2007>
SuMoTuWeThFrSa
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

Syndication