Copied to clipboard

Flag this post as spam?

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


  • Elliot Taylor 1 post 21 karma points
    Apr 22, 2014 @ 12:52
    Elliot Taylor
    0

    Poor Performance when using RelationService v7.0.3

    I haven't been using Umbraco for long so I may be doing things incorrectly, but I have a website where members can log in and 'like' articles. I am using a relation between an 'article' and a 'member' to represent liked articles.

    I am using the code below to retreive all liked articles for a member:

    likedArticles = string.Join(",", Services.RelationService.GetByChildId(memberId)
                        .Where(r => r.RelationType.Alias.ToLower() == "likes")
                        .Select(r => r.ParentId.ToString()));

    However, this code seems to generate many database calls in a loop (see output from umbDebug below).

    I have tried splitting the LINQ clause into multiple lines but it still loops through each object in the relation.

    Any ideas on how this can be more efficient? Should I not be using relations for my scenario?

    Any help would be very much appreciated.

     

    Debug Output:

    Controller: LikesController.GetArticlesLikedByMember
    T+76.4 ms
    Reader
    23.7 ms
    MoveNext MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    SELECT *
    FROM [umbracoRelation]
    WHERE ([umbracoRelation].[childId] = 13795)  
    Controller: LikesController.GetArticlesLikedByMember
    T+101.2 ms
    Reader
    20.8 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1072;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+122.8 ms
    Reader
    21.0 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+144.8 ms
    DUPLICATE Reader
    20.6 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1073;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+166.2 ms
    DUPLICATE Reader
    20.5 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+187.7 ms
    DUPLICATE Reader
    20.7 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1074;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+209.3 ms
    DUPLICATE Reader
    21.7 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+231.9 ms
    DUPLICATE Reader
    20.6 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1075;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+253.4 ms
    DUPLICATE Reader
    20.6 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+275.0 ms
    DUPLICATE Reader
    20.5 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1076;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+296.4 ms
    DUPLICATE Reader
    20.6 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+317.8 ms
    DUPLICATE Reader
    24.1 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1077;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+342.8 ms
    DUPLICATE Reader
    20.5 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+364.3 ms
    DUPLICATE Reader
    20.4 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1078;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+385.6 ms
    DUPLICATE Reader
    20.4 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+406.8 ms
    DUPLICATE Reader
    20.3 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1079;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+427.9 ms
    DUPLICATE Reader
    20.6 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+449.5 ms
    DUPLICATE Reader
    22.5 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1080;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+473.1 ms
    DUPLICATE Reader
    20.7 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+495.0 ms
    DUPLICATE Reader
    20.3 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1081;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+516.3 ms
    DUPLICATE Reader
    20.8 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+538.6 ms
    DUPLICATE Reader
    20.4 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1082;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+560.0 ms
    DUPLICATE Reader
    20.2 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+581.3 ms
    DUPLICATE Reader
    20.4 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1083;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+602.8 ms
    DUPLICATE Reader
    20.3 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+624.1 ms
    DUPLICATE Reader
    20.3 ms
    MoveNext PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 1084;

    SELECT *
    FROM [umbracoRelation]
    WHERE (umbracoRelation.id = @0)  
    Controller: LikesController.GetArticlesLikedByMember
    T+645.4 ms
    DUPLICATE Reader
    20.7 ms
    MoveNext PerformGet Get PerformGet Get MoveNext Join GetArticlesLikedByMember Execute ExecutePageHierarchy ExecutePageHierarchy Render Execute ExecutePageHierarchy ExecutePageHierarchy Render
    DECLARE @0 int = 2;

    SELECT *
    FROM [umbracoRelationType]
    WHERE (umbracoRelationType.id = @0)  
  • Paul Dermody 31 posts 110 karma points
    Sep 05, 2016 @ 20:37
    Paul Dermody
    0

    Hi,

    I know this is an old post. But I thought you might be interested in this: https://our.umbraco.org/forum/using-umbraco-and-getting-started//79803-significant-performance-bottleneck-in-relationservice#comment-79803

    All the best,

    Paul.

Please Sign in or register to post replies

Write your reply to:

Draft