In recent days I’ve had a look at performance in Microsoft Flow and how to improve the performance of my flows with easy steps or patterns. We all know that nested Apply to each steps are not a great idea or maybe …
Therefore I started by creating some nested apply to each steps. If you do a bad job then do at least a really bad job!
To run all of this within an apply to each about 45 times takes 16 minutes. Pretty performance poor isn’t it?
I decided to optimise the flow a bit by adding Select statements straight after the Get Items actions and I gained 10 minutes. Simply by adding all the complexity into a single select my flow started to perform a lot better
I always thought that the usage of the variables would really cause the performance trouble as Flow is waiting for locks on the variables. Both versions of the flow are using the same number of variables and the same number of compose actions.
Time to look at the details.
Within the original Flow within the Apply to each there were a lot of expressions used. Moving these expressions from the nested apply to each steps to a single Select action reduced the complexity in the nested Apply-to each steps.
In the optimised flow I put all my expressions in the Select action.
This now means that as I use a Set Variable inside my apply for each becomes very simple a set of references to my data returned by the select.