Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Peck 687 posts 1863 karma points c-trib
    Jul 26, 2016 @ 14:19
    David Peck
    0

    DB calls during render?

    Looking at the mini profiler I can see several DB calls being made during render that relate to nuPickers. enter image description here

    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

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jul 26, 2016 @ 14:28
    Hendy Racher
    0

    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

  • David Peck 687 posts 1863 karma points c-trib
    Jul 27, 2016 @ 08:23
    David Peck
    0

    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?

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jul 27, 2016 @ 09:13
    Hendy Racher
    100

    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

  • David Peck 687 posts 1863 karma points c-trib
    Jul 27, 2016 @ 12:12
    David Peck
    1

    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!

Please Sign in or register to post replies

Write your reply to:

Draft