“The flow takes tens of minutes, even hours to complete, why is Power Automate so terribly slow? Can I do something about it?”
When you run a flow, it always takes a while until the flow completes. It can be a few seconds for the simple flows or many days for flows including some manual task. And then there’re all the flows in between, running tens of seconds, minutes, hours… some of them running much longer than you’d wish/expect. Why does that happen? What’re the most common causes of a slow flow?
It’s mainly about the ‘Apply to each’
If your flow is running really slow, take a look on what loops it contains. The more ‘Apply to each’ actions, especially ‘Apply to each’ inside another ‘Apply to each’, the slower the flow.
Loop to select a specific value
One example I’ve recently seen is a flow designed as below. The goal is to take all items, and from each item select a specific value and store it in a variable.
The more items there is, the more loops it’ll contain, and the longer will the flow run. It’s always better and many times faster to use the ‘Select’ action instead of such ‘Apply to each’ and ‘Condition’.
Loop to process only some of the items
Another example of a useless loop is to process only specific items. For example, send an email for items where some date is today.
If you use a ‘Condition’ inside ‘Apply to each’ to filter the items, you’ll end up processing all the items. All items in the specific data source just to find a few of them: always use filters instead of these loops.
It can be a filter directly in an action, e.g. in ‘Get items’ or ‘List rows…’ or any other action with such possibility.
If there’s no such option there’s still the ‘Filter array’ action to filter the items/rows/anything later.
Loop to create / delete many items
The last type of loop that can be improved is when it just has a lot of work to do. It’s not selecting anything, it’s not possible to filter, but it needs to repeat some action many times. For example, create or delete thousands of items.
This is a bit more complicated than the two points before, but at the same time it’s not that common. I’m mentioning it mainly to show you that there’re also other options to reduce the number of loops.
If you feel that your Power Automate flow is running too slow, it’s very often due to some ‘Apply to each’. The more items you send in a loop, the longer it’ll take to process them, in some cases even hours. Most of such flows can be improved following just the first two concepts – ‘Select’ to select some value(s) for further processing and filter whenever possible. You’ll still have some ‘Apply to each’ in the flow, but that’s fine as long as you don’t send more items than necessary inside. A few ‘Select’s and a few ‘Filter array’s and your flow can run 8 minutes instead of 20 hours…