Copied to clipboard

Flag this post as spam?

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


  • Mark Cassar 5 posts 81 karma points
    Mar 20, 2016 @ 09:43
    Mark Cassar
    0

    Umbraco Querying Performance

    I have a question with regards to querying performance in Umbraco.

    Let's imagine you have a Document Type Property which has got fields such as

    • Price - int
    • Reference Code - string
    • Property Type - nuPicker Lucene Typeahead List which stores the relation of the Property with the Property Type (e.g. villa, bungalow etc.) in JSON format

    In order to query the above, let's say you want to load the properties who have a price less than 100,000 and which are of type "Villa" which has a PropertyType ID of 192.

    Let's say all the properties are children of a parent node 'Properties', with ID 1023.

    If we do something like the following:

        var propertiesNodeId = 1023;
        var searchPropertyTypeId = 192;
        var filteredProperties = Umbraco.TypedContent(propertiesNodeId).Children.Where(x => 
        (x.GetPropertyValue<int>("price") < 100000) && 
        (x.GetPropertyValue<nuPickers.Picker>("propertyType").PickedKeys.Contains(searchPropertyTypeId.ToString())));
    

    Would this mean that it would be loading all the properties in memory and then filtering them using those criteria? Is this approach recommended?

    Also, for pagination, when you use Skip() and Take() would it also be initially loading them all in memory and then just skipping / taking the required?

    In terms of querying performance, what would be the best option to do such a search / filtering?

    Thanks in advance for your help!

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Mar 21, 2016 @ 08:25
    Ismail Mayat
    0

    Mark,

    Use an examine search will be super fast. You may need to use Gatheringnode data event to get the nupicker field which I am assuming is stored as csv set up to be injected into the index as space separated list.

    Regards

    Ismail

  • Mark Cassar 5 posts 81 karma points
    Mar 21, 2016 @ 08:32
    Mark Cassar
    0

    Thanks a lot for your reply. I am sure that Examine will provide a super fast search.

    Still, in reply to my question above, would the above code end up loading all the data from the DB in memory and then filtering them out through the Where, Skip and Take methods?

Please Sign in or register to post replies

Write your reply to:

Draft