Optimizing Batch Updates in Data Store

Intro

With the latest App Connect 2 update, thanks to the new signals we are using there, whenever you update any value in the Data Store it automatically updates anything that uses it on your page. That is great, as there are no delays of any kind and everything runs faster than the previous App Connect versions. For example - you update product quantity in a shopping cart and the calculations are made immediately, so the totals are updated super fast.

There are, however, some cases where this may cause some side effects such as slow downs or delays on your pages. For example - you are using App Connect Flows, where you loop through hundreds (or thousands) of records, insert or upsert these records into the Data Store.
In that case you don’t need the data on your page to update after each of the record is inserted or updated, instead you want to update it only after the loops and insert/update cycles are finished.

That’s why we integrated two new methods in the Data Store component - Start Batch and End Batch. These new methods are helpful in cases like this, so they prevent the side effects while doing batch updates in the Data Store.

Start Batch

Start Batch prevents the Data Store from updating the data on the page. You can call it before a batch insert/update action in the Data Store.

So in our example we have an App Connect Flow, which loops through lots of records and does batch update in the Data Store:

Add a new step just before the loop (repeat) that runs the batch updates:

Add a Run step:

And pick an action:

Under Data Store add Start Batch, and click the select button:

You can see the Start Batch action will be called just before the batch updates run:

End Batch

You call End Batch when the batch update is done, this will update the data of the Data Store and it will display all the changes on the page.

So add a new step after the repeat:

Add a Run step:

And pick an action:

Under Data Store add End Batch, and click the select button:

You can see the Start Batch action will be called just after the batch updates are finished:

The data on the page will update now.

5 Likes