Sunday, November 27, 2011

Hidden Gem of Sitecore Page Editor


During performance profiling of Page Editor I’ve noticed that the “My Items” button was taking a lot of CPU time to render. ANTS Performance Profiler was very kind to tell me that with no hesitation.

If you don’t know what I am talking about, this “My Items” button shows the number of items locked by the context user:
image

and basically runs the following query:
Database.SelectItems("fast://*[@__lock='%\"" + Context.User.Name + "\"%']");


Since I was running on a fairly large customer database, this was quite expensive, specifically, taking more than 200ms.
One of my colleagues helped me discover that this behavior actually depends on the following setting which is not defined in web.config by default: “WebEdit.ShowNumberOfLockedItemsOnButton” and thus defaults to “true” always.
So in order to avoid such overhead on every Ribbon.Render, simply introduce this setting in web.config (even better in auto-include config file) and set it to “false”:
<setting name="WebEdit.ShowNumberOfLockedItemsOnButton" value="false" /> 

This should definitely speed things up for everyone in Page Editor.
Please share if this made the difference for your installation.

4 comments:

7bft said...

Hi Alex,

we had the same issue but mainly due to the workbox button. It also queries for all items assigned to the current user.
Since I currently have approx. 150.000 items in the master db and 22mio records in the VersionedField table this is really unuseable for large DBs.
We removed the two buttons alltogether, but it's good to know there is a hidden config setting for this....

Cheerz, Hannes.

varunvns said...

Simple yet very effective!

Superb gain in performance on disabling that!
Thanks Alex...

Mikkel Holck Madsen said...

Hey Alex,

do you know when this setting was implemented? We are implemening alot of Sitecore Intranet Portal, these are only on Sitecore 6.2/6.3.

We ran into the problem long time ago, as all useres on the intranet will get the webedit ribbon. we also decided to remove the buttons, to get preformance instead of features.

Robert Crowe said...

Using 7.1 this error started when I restored the databases from backups on another machine. I was able to resolve it by rebuilding the search index:

Desktop > Control Panel > Databases > Rebuild the Search Index

I also cleaned up the databases and rebuilt the link database, but those didn't seem to fix it.