I wanted to share my /MacroPartial Custom Label code because I was able to greatly improve the performance of the admin by switching from calling the ContentService.GetById(key) for every option in the NuPicker, to using the Examine InternalIndexer instead. I was rendering 500+ items per NuPicker. Some doctypes had 2-3 NuPickers, and the real killer was putting a NuPicker in an Archetype datatype which let the admin users dynamically add as many as they wanted to the node! 10 pickers each loading 600+ options from the DB --> bad performance, even some locking of the web server.
Bad way:
IContent ic = ApplicationContext.Services.ContentService.GetById(Convert.ToInt32(Model.MacroParameters["key"]));
Good way:
var intSearchProvider = ExamineManager.Instance.SearchProviderCollection["InternalSearcher"];
var criteria = intSearchProvider.CreateSearchCriteria("content");
var filter = criteria.Id(Convert.ToInt32(Model.MacroParameters["key"]));
var results = intSearchProvider.Search(filter.Compile());
if (results.Any())
{
var result = results.First();
string alias = result.Fields["nodeTypeAlias"].ToUpper();
CustomLabel Examine example
I wanted to share my /MacroPartial Custom Label code because I was able to greatly improve the performance of the admin by switching from calling the ContentService.GetById(key) for every option in the NuPicker, to using the Examine InternalIndexer instead. I was rendering 500+ items per NuPicker. Some doctypes had 2-3 NuPickers, and the real killer was putting a NuPicker in an Archetype datatype which let the admin users dynamically add as many as they wanted to the node! 10 pickers each loading 600+ options from the DB --> bad performance, even some locking of the web server.
Bad way:
IContent ic = ApplicationContext.Services.ContentService.GetById(Convert.ToInt32(Model.MacroParameters["key"]));
Thanks for sharing :) the ContentService hits the database, but how about using:
IPublishedContent content = UmbracoHelper.TypedContent(Convert.ToInt32(Model.MacroParameters["key"]))
This NuPicker options needs to include unpublished content, which AFAIK, there is no cached API to query, hence the Examine technique.
Arrh, all makes sense now.
is working on a reply...