If you need to get more than 5000 items from a SharePoint list, there are a number of different approaches. I’ve written up three different ways to solve the problem, which return exactly the same result, but have very different execution times. To get an overall understanding of this problem, check out the YouTube video I produced:
My requirement is to return 17,000 SharePoint list items to a PowerApp. I used Power Automate to get the data but found the standard “Get Items” action to be too slow. A good user experience is essential for application acceptance.
Eventually, I was able to reduce the amount of time that the Flow takes to retrieve the items from 2 minutes down to 8 seconds! That’s 13 times faster!
Since I originally wrote this post, I have figured out a method that is even easier and faster! Check it out here.
Links to my sample data and all the flows created are at the end of the post.
My example data looks like this:
It’s 7 columns wide, 17,000 rows of data. Here is how long it took Power Automate to execute the flow with execute each method:
Method | Time to Execute |
---|---|
Standard “Get Items” | 111 Seconds |
Standard “Get Items” with Select Action | 67 Seconds |
Retreiving same data with SharePoint API | 31 Seconds |
Retreiving same data with SharePoint API and two parralel queries | 19 Seconds |
Retreiving same data with SharePoint API and four parralel queries | 13 Seconds |
Same as above with optimised flow | 8 Seconds |
The table shows the results from six variations on three different themes. The fundamental principal behind each method is a “Do until” loop which collects the entire contents of a SharePoint list into an array. Each method has some pro’s and cons.
Which method to use?
The right method to use, depends on your circumstances. Here are some suggestions on what method may work best for you:
- If your flow is not time sensitive, just use the standard “Get Items” action with a “Do Until” Loop in Power Automate. The flow is simple and easy to build.
Get more than 5000 items from SharePoint with Power Automate - If you are already using the “Get Items” method but need it to be a bit faster, enhance the speed of it by adding the “Select” action.
Get more than 5000 items from SharePoint with Power Automate - If the performance gained from the “Select” action still does not meet your requirements, switch to using the SharePoint API. It is almost the same as using “Get Items”, but drastically faster.
Use the REST API in Flow to get over 5000 items from SharePoint - Finally, using parallel execution to retrieve chunks of SharePoint list data simultaneously increases speed further. But it does make the flow more complicated.
Combine SharePoint API & Flow Parallel branches for Performance
Why is the SharePoint Get Items action so slow?
The “Get Items” from SharePoint in Power Automate is very slow. The primary reason is the size of the payload that it returns from SharePoint. In addition to returning the columns defined in your SharePoint view, it also returns many other columns and metadata.
A single row of the sample data above results in this from SharePoint:
{ "@odata.etag": "\"1\"", "ItemInternalId": "1", "ID": 1, "Title": "Terry", "EmpNo": 1.0, "Last": "Carter", "Furloughed": 1.0, "Telephone": "(462) 723-7695", "Email": "[email protected]", "Brand": "PowerBI", "{Identifier}": "Lists%252f5000%2bItem%2bTest1%252f1_.000", "{IsFolder}": false, "{Thumbnail}": { "Large": null, "Medium": null, "Small": null }, "{Link}": "https://accendo1.sharepoint.com/sites/DocumentManagementTest/.....", "{Name}": "Terry", "{FilenameWithExtension}": "Terry", "{Path}": "Lists/5000 Item Test1/", "{FullPath}": "Lists/5000 Item Test1/1_.000", "{HasAttachments}": false, "{VersionNumber}": "1.0" }
That’s a huge amount of extra fields, which results in a massive payload. 5,000 rows of my sample data created a JSON response which was 3,545 KB.
The same 5,000 rows of data when passed through the “Select” action produces a JSON response which looks like this:
{ "Id": 1, "Title": "Terry", "EmpNo": 1.0, "Last": "Carter", "Furloughed": 1.0, "Telephone": "(462) 723-7695", "Email": "[email protected]", "Brand": "PowerBI", "ID": 1 }
For the same 5,000 records, the JSON response in flow was only 772 KB – A massive reduction. So passing the response from Get Items through the select action can make a big difference to how quickly your flow will run, and it is super easy to do.
Use the Sharepoint API for maximum speed
Although the “Select” action in Power Automate described above improves the speed of a flow within a do…until loop, the “Get Items” action is still retrieving a lot of unwanted data from SharePoint.
Using the SharePoint API allows you to get exactly the data you want without retrieving any unwanted columns or metadata.
Fortunately, this is very easy to do using the SharePoint API using the “Send an HTTP request to SharePoint” action. Compare these two flow actions:
These two actions, essentially perform the same operation, but the second one returns only the requested columns. Here is the difference in execution time:
Use Parallel Branching to get batches of 5000 items simultaneously.
Using the SharePoint API to get list data into Power Automate makes a huge difference to the speed of the operation. But it still gets the data in batches of 5000 blocks. With my 17,000 row sample the do-until loop has to execute four times to collect all of the data, all of which takes valuable time.
By using the parallel branch actions in Microsoft Power Automate we can engineer a solution which works much faster.
I tried collecting SharePoint data with two and four parallel branches. With four, I was able to get all 17,000 items in 8 seconds. The downside is that the flow is more complicated.
Conclusion
The standard Get Items action in Power Automate is fine for basic operations, but if you need more control, or speed, then there are better options.
I’m happy with the performance improvements I managed to create. Retrieving data from SharePoint is key to many applications and SharePoint handles the simultaneous requests well.
Example Data and Flows
You can download both my sample data and the flows discussed in these posts from here:
- Test Data to upload to SharePoint list
- v1 – Using the Get Items Action
- v2 – Using the Get Items Action with Select action
- v3 – Using SharePoint API to retrieve items
- v4 – Using SharePoint API and Two Parallel Execution Branches
- v6 – Using SharePoint API and Four Parallel Execution Branches
Adapting the flow to return SharePoint data to a jQuery grid
In the YouTube video above I also provided a demo of a jQuery grid that drew data from the SharePoint list using Power Automate, you can view that demo here:
Demo of jQuery based grid retrieving SharePoint data via Flow
You can easily copy the source code from that page, the flow has been left unsecured so that you can try it out.