1
  1. Version of Mobile SDK Used: 9.2.1
  2. Issue found in Native App or Hybrid App: Native App
  3. OS Version: All
  4. Device: All
  5. Steps to reproduce: syncUp

We use SmartSync/SmartStore to sync offline data with Salesforce. However, we notice the slow performance of this process. It was implemented a long time ago in https://github.com/forcedotcom/SalesforceMobileSDK-iOS/blob/9f4daa6f28fb1dbeaeee0e611bd550ece66e408e/libs/MobileSync/MobileSync/Classes/Target/SFSyncUpTarget.h however, it does not solve our problem.

The Composite API (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_composite.htm) used in this implementation creates 25 subrequests (one record per subrequest) that are sent to Salesforce. However, each of these subrequests is handled separately, not as a batch (below example)

{
   "method":"POST",  
   "url":"\/services\/data\/v49.0\/composite",  
   "body":{  
      "compositeRequest":[
         {
            "method":"PATCH",
            "url":"\/services\/data\/v49.0\/sobjects\/xxx\/ExternalId__c\/123",
            "body":{
               "Name" : "name1",
               "RelatedRecord__r":{
                  "ExternalId__c":"12345"
               }
            },
            "referenceId":"local_1"
         },
        {
            "method":"PATCH",
            "url":"\/services\/data\/v49.0\/sobjects\/xxx\/ExternalId__c\/1234",
            "body":{
               "Name" : "name1",
               "RelatedRecord__r":{
                  "ExternalId__c":"12345"
               }
            },
            "referenceId":"local_2"
        }
     ],
   "allOrNone":false
   }
}  

As an effect, we are getting the following stamps from the database.

enter image description here

The sync of 411 records started at 11:33:54 (first record) and was finished at 11:36:28 (last record) so very long time - about 2:30 minutes.

We are using Salesforce SDK in 9.2.1, it is our custom application with SDK package. We use SmartStore and SmartSync. Did you observe the same issue?

Created issues in github https://github.com/forcedotcom/SalesforceMobileSDK-iOS/issues/3496 https://github.com/forcedotcom/SalesforceMobileSDK-Android/issues/2293

3
  • 1
    Hi and welcome to SFSE. There doesn't appear to be a question here. You should probably edit the question to frame a question around improving performance of the cited SDK sync code then move the answer information you have included in the question out into a self-answer.
    – Phil W
    Commented Apr 25, 2022 at 15:27
  • Have you thought about using briefcases?
    – Phil W
    Commented Apr 25, 2022 at 15:29
  • Thanks, @PhilW, adjusted to your reco, hope that works now. I think Briefcases works with Field Service mobile app, while we have our custom one working on SmartSync/SmartStore. Not sure if we can connect the briefcase to our custom app if the application does not have code to communicate with it. I guess that briefcase itself it not within SDK library: developer.salesforce.com/docs/atlas.en-us.mobile_sdk.meta/…
    – PatrykK
    Commented Apr 26, 2022 at 11:26

1 Answer 1

1

After investigation, we would recommend implementing different API for data synchronization https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobjects_collections_upsert.htm

PATCH /composite/sobjects/xxx/ExternalId__c

{
    "allOrNone" : false,
    "records" : [{
        "attributes" : {"type" : "xxx"},
        "Name" : "name1",
        "ExternalId__c" : "123",
        "RelatedRecord__r":{
                  "ExternalId__c":"12345"
               }
    }, {
        "attributes" : {"type" : "xxx"},
        "Name" : "name1",
        "ExternalId__c" : "1234",
        "RelatedRecord__r":{
                  "ExternalId__c":"12345"
               }
    }]
}

In that case, we can push as one batch - not single records in the different sub-requests:

enter image description here

It can be a game-changer in the sync process.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .