Copied to clipboard

Flag this post as spam?

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


  • kristian schneider 190 posts 351 karma points
    Dec 05, 2012 @ 16:10
    kristian schneider
    0

    DescendantsOrSelf is slow in media section

    I have the following snip:

        var t = DateTime.Now;
        const int galleryRootNodeId = 1119;
        var root = new DynamicNode(galleryRootNodeId);
        var children = root.DescendantsOrSelf("Image").Items.OrderByDescending(n=>n.Id).take(10);
        var diff = DateTime.Now.Subtract(t).TotalMilliseconds;

    That get the newest 10 images in a folder in the media section.

    The problem is that it takes ALOT of time to traverse all the images and get the ten newest. There are around 2500 images and the depth of the folders are no more than 4 at most, which to me sounds pretty ok.

    Any sugestions ?

  • kristian schneider 190 posts 351 karma points
    Dec 06, 2012 @ 12:26
    kristian schneider
    0

    Right.

    I came up wih a solution my self and getting speed gain from 200180 milliseconds to 187 ms

     var t = DateTime.Now; 
    const int galleryRootNodeId = 1119; 
    var root = new Media(galleryRootNodeId); 
    var children = root.GetDescendants(); 
    var list = children.Cast().ToList(); 
    var diff = DateTime.Now.Subtract(t).TotalMilliseconds; 
Please Sign in or register to post replies

Write your reply to:

Draft