cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dougallen
Level: Powered On

Flow very slow occasionally in a condition with switch

I have a Flow in which I have a condition that splits the flow into 2 different paths depending on the type of request (there are 2 types).  It does the exact same logic on both sides (like documentation population and creation), except that Type A pulls from one library and templates and Type B pulls from compeltely differently libraries and templates.  This was nice and fast when I just had one type, but since I have had to add a second.  This has really slowed it down.  Each switch has 15 cases to evaluate.  

 

For example, sometimes it runs in 45 seconds, and occassionaly it will take over 2 minutes.  If I look at the 2 min run, I see the time is on condition, but if I look at every individual action in it, it only adds up to about 15 seconds.  Where is this extra time come from?  The flow is already compiled or whatever by now.  Any way to speed this up?

 

Here's the main overall scope with everything in it that shows 2 min:

SlowFlow_scope.jpg

And if I drill into the switch, these are the actions for it:

SlowFlow_insideswitch.jpg 

 

4 REPLIES 4
Highlighted
Super User
Super User

Re: Flow very slow occasionally in a condition with switch

Welcome to the wacky world of conditional loops! Where time is of essense, but it doesn't really seem to matter. What or how the logic is different on each run of your Flow is a mystery for the ages that all Flow experts would love to know. However, we have no insight into the backend of just how these actions are performed but we do have a few things we can do that may help boost overall Flow performance. 

How you may ask? Well, I highly suggest that you take a look at the Flow Cookbook post How to Avoid Do-Until Loops and Improve Performance, by @degvalentine for some insight. In short, the idea is to filter out the data that is available for use by the condition to the absolute minimum, so the condition has to crawl and confirm as few datapoints as possible. Starting with an optimized condition, is really the only way we can insure that the condition runs optimally. 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

dougallen
Level: Powered On

Re: Flow very slow occasionally in a condition with switch

Thanks and I know to do that, but that really isn't relevant to my situation.  The flow runs on the trigger "when an item is created", so I don't need to get data and I already have context to a single item.  When I go back and get different items, I pass the single item ID.  Nowhere am I doing a get all items that needs odata filtering.  The screenshots you see are basically "current item".  I appreciate it though!  I am interested where I see 2 min, but every action inside it only amounts to 15 seconds.  

Super User
Super User

Re: Flow very slow occasionally in a condition with switch

You are utilizing a condition, which will always contain a "catch all" from the previous steps for the conditional comparison and for each loop. Whatever is included in your Build Levels String step or above, is likely more data than you need to determine the output of your condition.

If you first created a variable specific to the datapoints that you are comparing with the condition, that alone would greatly improve your condition's performance, as the condition would know beforehand that you want to check that variable, and that variable alone.

Filtering before your condition doesn't have to apply to just the data, it can and should apply to the logic/data points you're utilizing for your conditional logic. You can also take this one stop further and build nested conditions within the conditional tree itself, or run parallel conditions or perhaps offload it to an Azure Function to boost performance.

What is best is dependent on your data and Flow, but it is important to remember that filtering and improving performance for your conditions can be extended well before you even get to your data. We aren't sure where the performance hiccup is happening in your Flow, so a top down approach is the only logical way to begin optimizing it.

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Community Support Team
Community Support Team

Re: Flow very slow occasionally in a condition with switch

 

Hi @dougallen ,

 

Are you using Apply to each?

If so, it is recommended to increase the degree of Parallelism and speed up execution.

Image reference:

19.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users Online
Currently online: 102 members 4,322 guests
Please welcome our newest community members: