The data integration and reporting available in Marketing Cloud is what makes it such a powerful marketing tool. Writing data takes time, so bundling the returned records into a large array and using the SSJS Rows.Add() function to add up to 2,500 (again, we recommend 1,000 as that seems to perform more reliably) records at a time, which will help keep your automation running efficiently.
Second, you’ll want to record your data in bulk. This will keep the number of records returned much more manageable. Keep track of the latest journey history line you’ve synced for each business unit and only query from that timestamp on. The first is the tried and true database rule: limit your queries. There are two strategies that will help keep your automation running quickly. We found that requesting 1,000 records at a time was the most efficient and least likely to cause problems.
You can specify the record page you’d like to retrieve and the number of records returned in a single call by using the “interaction/v1/interactions/journeyHistory/search” endpoint with $page and $pageSize parameters.