Copied to clipboard

Flag this post as spam?

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


  • Jeremy Coulson 61 posts 143 karma points
    Aug 13, 2020 @ 13:42
    Jeremy Coulson
    0

    How do I find out what is calling a duplicate query in miniprofiler?

    Hello!

    We're trying to figure out some speed issues on our site. Running the miniprofiler, I see this query is being run four times:

    DECLARE @0 nvarchar(40) = N'c66ba18e-eaf3-4cff-8a22-41b16d66a972',
            @1 int = 1052,
            @2 int = 1;
    
    SELECT cmsPropertyData.*
    FROM cmsPropertyData
    INNER JOIN cmsPropertyType
    ON cmsPropertyData.propertytypeid = cmsPropertyType.id
    INNER JOIN 
            (SELECT cmsContent.nodeId, cmsContentVersion.VersionId FROM [cmsDocument]
    INNER JOIN [cmsContentVersion]
    ON [cmsDocument].[versionId] = [cmsContentVersion].[VersionId]
    INNER JOIN [cmsContent]
    ON [cmsContentVersion].[ContentId] = [cmsContent].[nodeId]
    INNER JOIN [umbracoNode]
    ON [cmsContent].[nodeId] = [umbracoNode].[id]
    INNER JOIN [cmsContentType]
    ON [cmsContentType].[nodeId] = [cmsContent].[contentType]
    WHERE (([umbracoNode].[nodeObjectType] = @0))
    AND (([umbracoNode].[parentID] = @1))
    AND ([cmsDocument].[newest] = @2)
    ) as docData
    ON cmsPropertyData.versionId = docData.VersionId AND cmsPropertyData.contentNodeId = docData.nodeId
    ORDER BY contentNodeId, versionId, propertytypeid
    

    I've run this query in SQL Server, but the results don't get me anywhere closer to understanding what's going on. Is there a way to drill down deeper to see exactly where some query is being called? I don't see anything obvious in the Razor view indicated in the miniprofiler.

    Thanks!

    Jeremy

  • Chris Norwood 102 posts 549 karma points
    Aug 13, 2020 @ 14:40
    Chris Norwood
    0

    Hi there,

    Looking at the query, it seems to be trying to get all nodes of a specific type that live under the node with ID 1052 (and are the newest version).

    Does the view in question have a for loop that does something like (from memory)

        foreach (var item in list.where(x=> x.DocumentTypeAlias == "docTypeAlias"))
        {
    //Do stuff with item in here
        }
    

    If so, where does "list" come from? Is the content service perhaps being used in the view? (Are you able to post the code of the view)? :)

    Thanks,

    Chris.

  • Jeremy Coulson 61 posts 143 karma points
    Aug 13, 2020 @ 15:01
    Jeremy Coulson
    0

    Chris,

    I don't see anything like that. In fact, in an act of desperation, I removed almost all of the code from the view except for the layout:

    @inherits UmbracoTemplatePage<OurSiteHomeNew>
    @{
        Layout = "/Views/Shared/OurSite/_Layout.cshtml";
    }
    

    Even with this, I see the duplicated queries. I don't see anything in _Layout.cshtml that looks relevant. Actually, the only loop in there is something that gets body classes:

    var bcs = currentPage.GetPropertyValue<string>("bodyClassSelector");
        if (!string.IsNullOrEmpty(bcs))
        {
            string multipleBodyClass = "";
            foreach (var item in bcs.Split(','))
            { multipleBodyClass += item + " "; }
            bodyClass = (bodyClass + " " + multipleBodyClass).Trim();
        }
    
  • Yakov Lebski 473 posts 1878 karma points
    Aug 13, 2020 @ 15:23
    Yakov Lebski
    0

    possible cause to this issues what you have images with # in src, it can cause double call to page

    <img src="#" />
    
  • Chris Norwood 102 posts 549 karma points
    Aug 13, 2020 @ 15:50
    Chris Norwood
    0

    OK - are you able to identify which document has the ID 1052 in the back office (if it is a document - it might be something totally different like a parent document type, nested content perhaps)?

    It's been a while since I looked at the Umbraco 7 DB but I had a look in an old one and got all sorts of odd values using that query (modified to return children of the main site node in this particular site).

    I modified the query to get the property type name/description too:

     DECLARE @0 nvarchar(40) = N'c66ba18e-eaf3-4cff-8a22-41b16d66a972',
            @1 int = 1052,
            @2 int = 1;
    
    SELECT cmsPropertyData.*,
    pt.Description,
    pt.Name
    FROM cmsPropertyData
    INNER JOIN cmsPropertyType pt
    ON cmsPropertyData.propertytypeid = pt.id
    --inner join cmsDataType dt on dt.pk = pt.dataTypeId
    INNER JOIN 
    (SELECT cmsContent.nodeId, cmsContentVersion.VersionId, cmsContentType.description FROM [cmsDocument]
    INNER JOIN [cmsContentVersion]
    ON [cmsDocument].[versionId] = [cmsContentVersion].[VersionId]
    INNER JOIN [cmsContent]
    ON [cmsContentVersion].[ContentId] = [cmsContent].[nodeId]
    INNER JOIN [umbracoNode]
    ON [cmsContent].[nodeId] = [umbracoNode].[id]
    INNER JOIN [cmsContentType]
    ON [cmsContentType].[nodeId] = [cmsContent].[contentType]
    WHERE (([umbracoNode].[nodeObjectType] = @0))
    AND (([umbracoNode].[parentID] = @1))
    AND ([cmsDocument].[newest] = @2)
    ) as docData
    ON cmsPropertyData.versionId = docData.VersionId AND cmsPropertyData.contentNodeId = docData.nodeId
    ORDER BY contentNodeId, versionId, propertytypeid
    
    • Not sure if that might give you any clues?

    I looked here:

    https://our.umbraco.com/forum/developers/api-questions/3119-Retrieve-node-type-from-ID

    And it seems that the GUID being used in the query is for something called:

    umbraco.cms.businesslogic.web.Document

    This sounds like it's likely to be a fundamental part of the CMS - it could just be how Umbraco 7 gets the property data for the document...

  • Jeremy Coulson 61 posts 143 karma points
    Aug 13, 2020 @ 17:37
    Jeremy Coulson
    0

    Chris,

    1052 is the ID of our main home node. It looks like the other stuff in the results of the updated query are values from our blog (which we no longer use), our configuration node, and a folder full of content that is no longer served.

    What concerns me is that the blog and that folder are no longer in use and many of these configuration values are not used on the home page. However, if these queries are just how Umbraco functions, I can take that back to the team here and tell them.

  • Chris Norwood 102 posts 549 karma points
    Aug 13, 2020 @ 17:58
    Chris Norwood
    0

    Hi Jeremy,

    I can't say for certain (I don't work for Umbraco and I'm not an expert on the workings of the interactions of the CMS with the DB) but it looks to me like it's finding "old" data that is nevertheless the newest available - it's not checking for a published version - I know V8's DB has been redesigned quite a bit to make this sort of data retrieval more efficient.

    To make sure that code actually runs when the node is run you could create a RenderMvcController for the document type and debug it to see what happens in there and if the data somehow comes through on old properties or something? (See https://our.umbraco.com/documentation/reference/routing/custom-controllers)

    Thanks,

    Chris.

Please Sign in or register to post replies

Write your reply to:

Draft