Copied to clipboard

Flag this post as spam?

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


  • Dave Pearcey 46 posts 178 karma points
    Jan 27, 2020 @ 17:08
    Dave Pearcey
    0

    Querying Umbraco too slow

    Hi,

    I've got a list of 700+ items that im querying and getting the latest N results back, but as this list grows, it's getting slower and slower which is cauing me many issues. I read about using pure examine for this but have been struggling to wrap my head around how it works. Would anyone be able to help me out and turn my query into an examine query?

    This is for the chat functionality within a Game I've been building. basically gets the latest chat items that are either for the recipient, or have no recipient(for everyone).

    IEnumerable<IPublishedContent> chatItems = Umbraco.TypedContent(1082).Children().Where(x => x.IsVisible() && (x.GetPropertyValue("Recipient") == null || x.GetPropertyValue<int>("Recipient") == m.Id || x.GetPropertyValue<int>("Recipient") == 0)).OrderByDescending(x => x.CreateDate).Take(m.GetPropertyValue<int>("chatSize"));
    

    Any help is appreciated, thanks!

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Jan 27, 2020 @ 22:09
    Alex Skrypnyk
    0

    Hi Dave

    Maybe you can change something id document structure? For example, why do you need extra logic to check when getting nodes without recipient? Maybe you can store these nodes in some other place and then remove this logic.

    Examine is great for speeding up the performance, but if you can re-create a structure that it will be easier to access - this is the best.

    Thanks,

    Alex

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Jan 31, 2020 @ 23:51
    Alex Skrypnyk
    0

    Let us know how did you solve the issue.

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Feb 01, 2020 @ 17:06
    David Brendel
    0

    Hi Dave,

    I don't think and wouldn't recommend to store something like chat messages in the tree. I would store it in a custom table or elsewhere.

    Regards David

  • Dave Pearcey 46 posts 178 karma points
    Feb 03, 2020 @ 11:31
    Dave Pearcey
    101

    I originally got the idea from this article.

    https://skrift.io/articles/archive/testing-the-performance-of-querying-umbraco/

    What I wrote was:

    BaseSearchProvider searcher = Examine.ExamineManager.Instance.SearchProviderCollection["ChatSearcher"];
            ISearchCriteria searchCriteria = searcher.CreateSearchCriteria();
            IBooleanOperation searchQuery = searchCriteria
                .GroupedOr(new[] { "recipient", "type" }.ToList(), new[] { m.Id.ToString(), string.Empty, "0", "system" })
                .And()
                .Field("__IndexType", "content")
                .And()
                .OrderByDescending("sortOrder");
    
            ISearchResults searchResults = searcher.Search(searchQuery.Compile(), m.GetPropertyValue<int>("chatSize"));
    

    The result was a huge difference. It went from 2,200ms load (and growing), to a 35ms consistent load time.

Please Sign in or register to post replies

Write your reply to:

Draft