Showing results for 
Search instead for 
Did you mean: 
Super User
Super User

Flow - Apply to each - very slow

I have a Flow with a string variable (not super long, maybe a few hundred words).


The flow iterates (Apply to each) through a list of substitutions (just a two column list of 'string_to_find' and 'string_to_replace_with').


On each iteration, a Compose action perfroms a Replace function, taking the string variable and substituting any instance of 'string_to_find' with 'string_to_replace'. A Set Variable action then stores the updated string from the Compose step back into the variable and the loop goes round again.


The substitution table has 12 entries (so the apply to each runs 12 times).


The 'Apply to each' loop routinely taking more than 5 seconds to complete. Given that this is a simple set of string substitutions, I'm surprised at how slow this is.


Unfortunately I now need to create another Flow using similar a technique but with more looping required and currently this one is taking over 20 seconds using just a small amount of test data.


Is there some way I can speed this up? How much 'processing power' does Flow give? In my experience, Flow is very quick at transferring data (pushing/pulling to/from various services/sources) but any 'internal' processing (such as this example of string substitution) seems very slow.

Community Support
Community Support

Re: Flow - Apply to each - very slow

Hi @PaulD1,


Could you please share a screenshot of the configuration of your flow?


I suggest that you could run the flow in a good browser condition and there is no any other way to speed up the flow run.


Best regards,


Super User
Super User

Re: Flow - Apply to each - very slow

Hi Alice (@v-yuazh-msft)


Below are images of relevant part of the Flow and the time taken to run. You will see that it is doing a simple text substitution on each loop using a Replace function and saving the result back to a variable.


The loop consists of 12 rows of data, each with two columns (Element and Replacement) the idea is to add some HTML formatting codes to a block of HTML code. Two example rows are shown below:


    "Element": "<table>",
    "Replacement": "<table style=\"font-size:14px; border-collapse: collapse; width: 100%;font-family: Verdana,Serif; \">"
    "Element": "<thead>",
    "Replacement": "<thead Style =\"text-align: left; color: black; font-family: Verdana,Serif;background-color: #B5C3CB;\">"

For a simple set of text substitutions, 6 seconds seems excessive to me. As per OP I have some more complex scenarios where more loops are required and performance is becoming a problem.


I don't see how browser condition is relevant as all this runs server side.





Flow Slow Loop 1.pngFlow Slow Loop 2.png

Helpful resources


Super User Program Update

Three Super User rank tiers have been launched!


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021


New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!


Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (8,250)