which scenario Query Record gives less performance

As per the Documentation Query Record gives less performance than query Entity or Query Rule,   in case of query Entity we are getting the Data from DB but in case of Query Record the parameter is Record Type so in such case before using Query Record either Entity or Process backed Record is in place . so it means data also available  then In which scenario Query Record gives less performance?

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    ,

    Query Record is used if you already configured Record Type for your application.Which fetch the data from the record definition instead of hitting DB or Process Data again.
    In case ,if you don't have record configured with the required data ,we will go for either query entity/query rule/process analytics to fetch the data.
  • 0
    A Score Level 2
    in reply to Rama Thummala
    Hi,
    in such case Query Record should give More performance, because data already available in Record i no need to hit DB to fetch the data then why still query record gives less performance.
  • Hi Kiran, one of the reason could be sorting on multiple fields is not possible. Also by calling record directly you are adding an additionally layer which would call either process/DB/service. Hope this helps.
  • HI

    Do you query record when you want to add more filtering on the existing record type, especially when record is process backed record or a entity back record which has default filters and back ground work already done (this means data is already filtered via record and has specific data set to queried upon using queryrecord).

    Other than that if we need to query data form DB and it is much straight forward i would go for queryentity as it is much faster and agile.

    Even though you use queryrecord underneath data needs to be queried first for record then filter according to your queryrecord conditions hence it can be slow, there is caching mechanism for query record where if there is multiple request for the same record with same query with in same expression only, this will give some performance advantage as this will refer to the same dataset that retrieved in the first call.

    My personal preference is when ever you have the ability use queryentity. But sometime it is easier to use query record but that all depends on the requirement at hand.
  • 0
    Certified Lead Developer
    Hi i agree, Query Record gives less performance compared to Query Entity or Query Rule, because

    While working with Query Rule/Query Entity we directly hit the db along with the required columns as selection (not for Query Rule), paging & filtering options, and the response gets returned to us/End User.

    But while working with Query Record, first of all, the Record need to fetch the data(from DB/Process/External Service) along with their defined default filters, sorting and paging, and once the record gets the data, we need call query over this Record Type as part of queryrecord() function along with paging.
    So here the Query operation gets performed for twice, which can impact the performance relatively compared to Query Entity or Query Rule.


    Also while using Query Entity, if the call happens with the exact same parameters for more than once, the first call's result will be reused for further requests, because Appian uses JPA for DB related operations, and JPA uses Cache.

    Hope this will help you, to identify the difference with respect to performance between Query Record and Query Entity/Query Rule.