Copied to clipboard

Flag this post as spam?

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


  • Jim 17 posts 60 karma points
    Nov 19, 2017 @ 04:49
    Jim
    0

    Umbraco.MemberHasAccess is slow when member is logged in after upgrading to 7.7.6

    After upgrading from 7.6.5 to 7.7.6, Umbraco.MemberHasAccess is very slow on a small site with only 50 members.

    The issue is in a partial for the main menu. The relevant code is:

    @ { 
            var selection = CurrentPage.Site().Children.Where("Visible");
    }
    

    and

    @foreach (var item in selection)
    {
        if (Umbraco.MemberHasAccess(item.Id, item.Path)) { 
        <li class="@(item.IsAncestorOrSelf(CurrentPage) ? "active" : null)">
            <a href="@item.Url">@item.Name.ToUpper()</a>
        </li>
        }
    }
    

    The site is fast until the member logs in. After login this code can take more than a minute to execute. If I remove the if...MemberHasAccess bits the site is fast always.

    The mini profiler points out that this sql query is slow.

    DECLARE @0 nvarchar(40) = N'366e63b9-880f-4e13-a61c-98069b029728',
            @1 nvarchar(4000) = N'myMemberName';
    
    SELECT un.*
    FROM umbracoNode AS un
    INNER JOIN cmsMember2MemberGroup
    ON un.id = cmsMember2MemberGroup.MemberGroup
    LEFT JOIN (SELECT umbracoNode.id, cmsMember.LoginName FROM umbracoNode INNER JOIN cmsMember ON umbracoNode.id = cmsMember.nodeId) AS member
    ON member.id = cmsMember2MemberGroup.Member
    WHERE (un.nodeObjectType=@0)
    AND (member.LoginName=@1)   
    

    I confirmed that this query is the problem by running the query manually.

    The site uses SQL CE

    Has anyone else run into this?

  • Jim 17 posts 60 karma points
    Nov 19, 2017 @ 18:29
    Jim
    0

    Update - the same query generated in 7.6.5 is:

    DECLARE @0 nvarchar(40) = N'366e63b9-880f-4e13-a61c-98069b029728',
            @1 nvarchar(4000) = N'myMemberName';
    
    SELECT umbracoNode.id
    FROM [umbracoNode]
    INNER JOIN [cmsMember]
    ON [umbracoNode].[id] = [cmsMember].[nodeId]
    WHERE (([umbracoNode].[nodeObjectType] = @0))
    AND (([cmsMember].[LoginName] = @1))  
    

    The new query runs slowly on the 7.6.5 database and the old query runs quickly on the 7.7.6 database. The new query is clearly less efficient.

    I hope someone can provide some insight here.

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Nov 19, 2017 @ 19:38
    Dan Diplo
    0

    You might be better logging this as an issue on the issue tracker:

    http://issues.umbraco.org/dashboard

  • Jim 17 posts 60 karma points
    Nov 20, 2017 @ 20:55
Please Sign in or register to post replies

Write your reply to:

Draft