Announcement

Collapse
No announcement yet.

.Net API performance expectations -- very slow query

Collapse
X
 
  • Filter
  • Time
Clear All
new posts

    .Net API performance expectations -- very slow query

    I'm using the .Net API for what I have to think is a very common use-case: for a specific account, fetch all secondary contacts. Here's the code.

    Dim qry As New ObjectQuery(Of CommitCRM.Account)(LinkEnum.linkOR, maxUserCount)

    qry.AddCriteria(CommitCRM.Account.Fields.AccountMa nager, OperatorEnum.opEqual, AccountRecID)

    Dim results As List(Of CommitCRM.Account) = qry.FetchObjects()

    For an account with three contacts this query runs in a second or two. That's acceptable. An account with 75 contacts is taking around 30 seconds. At 190 contacts it takes almost three minutes.

    Any ideas?

    -- Craig

    Re: .Net API performance expectations -- very slow query

    Thank you for asking.

    From a quick look at your code it seems like all data fields are fetched, and this might mean many fields that you do not need.

    By default Accounts are fetched with their entire details behind the scenes, it would be certainly be faster if you load only the needed fields. For example, here is how you could fetch the accounts for only two field:

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

    Basically you need to pass a comma separated string with the field names that you need access to. Please give it a try and see whether it helps.

    Comment


      Re: .Net API performance expectations -- very slow query

      Thought it would be something like that! I didn't notice that FetchObjects() had that overload option.

      The 190 contact case is now down to 10 seconds, that's tolerable.

      Thanks so much for the quick response.

      Comment

      Working...
      X