“I’m adding multiple attachments to an email but the appending loop seems to be quite slow, how can I make loops faster in Power Automate?”
As already explained in previous articles, if your flow is slow, it’s probably due to unnecessary loop(s). An ‘Apply to each’ that can be often replaced with a select or a filter. But in some situations you still need a loop. For example, if there’s another action involved, e.g. ‘Get file content’ when preparing email attachments. Can these loops be at least a little faster?
If you really need a loop, one way to make it faster is to turn on parallelism. Go into the ‘Apply to each’ settings under the three dots…
… and enable the Concurrency control. Move the slider to the right to enable the maximum, 50 parallel branches running at once.
With this setting it’ll start processing all the items in the input array at the same time. Just be careful about using variables in parallel loops.
Use ‘Compose’ instead of variables
The other improvement comes with the use of ‘Compose’ action instead of a variable. If you used variable, you’d probably append to that variable in the loop and use it later in the flow.
Yet you don’t need a variable. You can use just the ‘Compose’ action where you define the input for each loop…
…and collect the composed output after the loop with an expression. You must always use an expression as it’s not something the designer will offer among the dynamic contents.
This approach will give you the same result as a variable, but in a faster way. Use it later in the flow in the same way as you’d use the variable, in this example to add the email attachments.
If there’s no way to remove loops from your Power Automate flow, yet you need them to run faster, you can try one of the solutions above. If you enable parallelism it’ll process up to 50 loop runs at the same time, giving a significant performance boost. And if you use the ‘Compose’ workaround instead of variables you can improve it even more.