Announcement

Collapse
No announcement yet.

C++ API fetchobject() very slow

Collapse
X
 
  • Filter
  • Time
Clear All
new posts

    C++ API fetchobject() very slow

    Hello,

    I'm using the C++ API to fetch all the contracts from commitCRM, but doing the FetchObject() on the 1300 contracts takes more than 7 minutes. Is this a normal behavior or is there something to do to speed this up?

    Best regards

    Re: C++ API fetchobject() very slow

    Thank you for asking. This it definitely not the expected response time. We cannot say what might be causing it and external factors may definitely be involved. In any case, without knowing the way it is implemented or how your code works here's a general recommendation:

    The default setting is the entire record is fetched with all details. It would be certainly be faster if you load only the needed fields. For example, here is how you could fetch the accounts (as an example) for only two fields:

    lstAccounts = objQuery.FetchObjects(RangerMSP.Account.Fields.Acc ountREC_ID.Key + "," + RangerMSP.Account.Fields.FileAs.Key)

    So, basically you need to pass a comma separated string with the field names that you need access to.

    Please apply the above to your use case and see how it goes.

    Comment


      Re: C++ API fetchobject() very slow

      Hello,

      Limiting to 2 fields takes 20 seconds, and with the fields that I need, it takes 3 minutes.
      Here is the parameter of FetchObjects() now:
      "FLDBCTACCRECID,FLDBCTAMOUNTSTART,FLDBCTCODE,FLDBC TRECID,FLDBCTCREATEDATE,FLDBCTENDDATE,FLDBCTUSER1, FLDBCTUSER2,FLDBCTNAME,FLDBCTRECTYPE,FLDBCTSTARTDA TE,FLDBCTCONTRACTTYPE,FLDBCTUPDATEDATE"

      This is better that the 8 minutes I had before, but still a bit long.
      This difference of execution time is a normal behavior?

      Comment


        Re: C++ API fetchobject() very slow

        Thank you for the update. The amount of data and the fields that you fetch do affect the processing time, just like happens in your case. The actual time duration that you specified sound too high. Putting external environment factors aside, do you really need to fetch 1300 records at once? How about filtering the resultset so it will only include the exact records that you need (in case you don't need them all up front). You can always fetch the next batch later.

        Comment


          Re: C++ API fetchobject() very slow

          Hello,

          I have been attempting to do exactly this with only one field and get very slow results as well. The goal is to be able to validate if an account exists in CommitCRM so we need to check against all our accounts.

          Is there something in my code that is causing this slowdown?

          public void IsValidAccount(String acct) {
          CommitCRM.ObjectQuery<CommitCRM.Account> accountSearch = new CommitCRM.ObjectQuery<CommitCRM.Account>(CommitCRM .LinkEnum.linkAND, 2000);

          List<CommitCRM.Account> accounts = accountSearch.FetchObjects(CommitCRM.Account.Field s.CompanyName.Key);

          foreach (CommitCRM.Account account in accounts) {
          if (account.CompanyName == acct) {
          accountValidity = true;
          break;
          } else {

          }
          }
          CloseConnection();
          }
          Is there an alternative to the above?

          Comment


            Re: C++ API fetchobject() very slow

            To validate whether an Account exists or not it should be enough to limit the query to 1 result, e.g. if at least one record is returned (Account with that name) then it exists. In the example above the default of 100 results was increased to 2000, and this creates too many objects for no reason. Instead either use the default or better reduce it to 1 (or 5) and then in the query itself build a filtering criteria that already check/compares the Account name - as a result only such account/s will be returned and if at least 1 record is returned - the account is found.

            Also, you need to only query the exact fields you need, this will also improve performance. So in this case, you can query only the key or name and you do not need to further query any field nor to later loop the results as if there's a single record return - account was found.

            Hope this helps.

            Comment


              Re: C++ API fetchobject() very slow

              This made it click for me. Thank you for your help and reply. This is working as intended now. Feels great!

              public void IsValidAccount(String acct) {
              CommitCRM.ObjectQuery<CommitCRM.Account> accountSearch = new CommitCRM.ObjectQuery<CommitCRM.Account>(CommitCRM .LinkEnum.linkAND, 1);
              accountSearch.AddCriteria(CommitCRM.Account.Fields .CompanyName, CommitCRM.OperatorEnum.opEqual, acct);

              List<CommitCRM.Account> accounts = accountSearch.FetchObjects(CommitCRM.Account.Field s.CompanyName.Key);
              foreach (CommitCRM.Account account in accounts) {
              if (account.CompanyName == acct) {
              accountValidity = true;
              break;
              } else {
              // continue...
              }
              }
              }

              Comment


                Re: C++ API fetchobject() very slow

                You are welcome and thank you for the update!

                Comment

                Working...
                X