Looking at the mini profiler I can see several DB calls being made during render that relate to nuPickers.
The query in question seems to return the config for one of my nupicker data types. On a second request it doesn't get called, but fairly soon (20 secs) after it will get called again.
Why would the render be requesting this config? I'm guess it is so that you can tell if it is XML or CSV, but if so then inspecting the format of the property's value would be a lot quicker.
Well my extension method nuPickers.Picker.AsGuids() appears to be the last place that it touches my code, which is this:
public static IEnumerable<Guid> AsGuids(this nuPickers.Picker picker)
{
return picker == null ? new Guid[0] : picker.PickedKeys.AsGuids();
}
To be clear, the reference to AsGuids in the code above is a reference to a different method of the same name(below), but the stack trace suggests this is never called.
public static IEnumerable<Guid> AsGuids(this IEnumerable<string> source)
{
foreach (var s in source)
{
Guid r;
if (Guid.TryParse(s, out r))
yield return r;
}
}
It is a dotnet source though. This is the source:
public class NewsSubjectPickerSource : IDotNetDataSource
{
IEnumerable<KeyValuePair<string, string>> IDotNetDataSource.GetEditorDataItems(int contextId)
{
var newsService = new NewsService(UmbracoContext.Current);
return newsService.Subjects.Distinct().ToDictionary(c => c.UniqueId.ToString(), c => c.SubjectName);
}
}
In GetEditorDataItems the call to newsService.Subjects just results in loading from cache (or fetching) some nested content IPublishedContent items, but I can't see anything here relating to nuPickers to which the DB call relates.
Is there any way to step the code and see at what point that DB call is made?
DB calls during render?
Looking at the mini profiler I can see several DB calls being made during render that relate to nuPickers.
The query in question seems to return the config for one of my nupicker data types. On a second request it doesn't get called, but fairly soon (20 secs) after it will get called again.
Why would the render be requesting this config? I'm guess it is so that you can tell if it is XML or CSV, but if so then inspecting the format of the property's value would be a lot quicker.
Is there any way to increase the cache time?
Cheers,
David
Hi David,
Can you post the razor snippet ? (I don't think nuPickers should query the DB on rendering - unless it's using DB relations)
Thanks, Hendy
Well my extension method
nuPickers.Picker.AsGuids()
appears to be the last place that it touches my code, which is this:To be clear, the reference to AsGuids in the code above is a reference to a different method of the same name(below), but the stack trace suggests this is never called.
It is a dotnet source though. This is the source:
In GetEditorDataItems the call to
newsService.Subjects
just results in loading from cache (or fetching) some nested content IPublishedContent items, but I can't see anything here relating to nuPickers to which the DB call relates.Is there any way to step the code and see at what point that DB call is made?
Hi David,
My guess would be that it's something to do with the check for the property-editor save format: https://github.com/uComponents/nuPickers/blob/master/source/nuPickers/Picker.cs#L102
which calls the Umbraco DataTypeService: https://github.com/uComponents/nuPickers/blob/master/source/nuPickers/Picker.cs#L191
Just had a chat with Jeavon, and this can be fixed by caching the pre-values after first query - will create an issue on GitHub.
Cheers Hendy
Hi Hendy,
That makes sense. I think it might be doing some caching already (though it could be my own caching) as I wasn't seeing this everytime.
Thanks for identifying the issue, I'll live with it for now and upgrade when I can.
Ta!
is working on a reply...