Improve Slow Workflow


Badge +11

I have this slow SITE workflow a co-worker created. I know it can be faster. It takes about 6 minutes and I believe it is because it keeps looking up items inside a loop. First off, I'm working with Nintex and SharePoint 2010. All that is supposed to be accomplished in this workflow is to set item permissions in the workflow. The evaluator needs permission to the workflow and other admins. But nobody else. Here is the deal:

 

1 list used as a lookup:

 

LU_GovEvaluator - It has evaluator name and competency in it

SAC - It has a field that points to the evaluator lookup. When that evaluator is selected, the competency automatically gets filled in because the competency comes from the lookup as well.

 

In the workflow, it is looking up the evaluator list. I am trying to prevent that.

 

Thanks!


17 replies

Userlevel 7
Badge +11

Hey Lisa,

can you check the graphical view of the workflow instance put your mouse over the actions to see which ones are taking the longest.

This may give you a better idea of what to look for.

My guess, is that the Set Item Permissions might be the culprit here.  But that's just a guess.

cheers,

Vadim

Badge +11

slowWorkflow2.jpg

Userlevel 7
Badge +17

Thanks Lisa, I think I have an idea, but can we see a look into a list item? And please point out which are used as lookups again. Thanks.

Badge +11

SAC_Item.jpg
The lookup is Government Evaluator. There is also another lookup Competency Code which is hidden. They both point to a lookup list that has the Government Evaluator name and Competency Code.

Userlevel 7
Badge +17

Ok, so these two lookup columns are separate and not linked as if selecting an evaluator will bring in the value of a competency. Is that correct?

Badge +11

Selecting an evaluator will populate the competency. And both of those lookup fields are coming from the lookup list Evaluators.

Userlevel 5
Badge +12

Hi Lisa,

Loops inside of loops doing queries into lists and setting permissions will always be a taxing and slow operation, especially when all thrown together.  Someone could also argue for all that it's doing, its not too bad in terms of speed since it appears this is more of a batch operation than a just in time interaction.  I'd say you could rewrite this workflow and perhaps have it fire on items individually at time of modification instead of doing it in batch if you require more real time speeds, but I as well as anyone knows that ultimately your business process will determine if this sort of rewrite is possible. 

Thanks,

Mike

Badge +11

What my co-worker did was create a site workflow that would be scheduled to run to move items to this list. After the items are moved, it calls this particular workflow which sets permissions to each item. Because it is pretty much copying the items in one fell swoop, you can't set the permissions then. Although I guess, there could be a workflow for when items are added. The question is will that be any faster?

Userlevel 7
Badge +17

Actually, it looks like the

For Each Competency loop runs 5 times total

The For Each SAC loop runs 108? times overall during its 5 times activation

For all of that to take 3 minutes and 4 seconds - that is really fast!

Badge +11

That is with 5 evaluators. Its test data. It will have approximately 14 evaluators and about 120 items for each evaluator in the main list.

Userlevel 5
Badge +12

Right on Andrew, for a batch operation not too bad at all.

Userlevel 5
Badge +12

Lisa - Is the concern with the 6 minutes that some of the items are being left "unprotected" during that time?  If so, you might want to protect them at the time in which they are created into that list.   Certainly dealing with a single item in a workflow should go much more quickly than dealing with them in batch, but "overall" there are far many more workflows that would be fired off than if doing so in batch.  Therefore it really comes down to a timing issue of when "x" needs to happen on a given item in the overall scheme of things.

Badge +11

No its not that they are being left unprotected during that 6 min. It is just that I was concerned that it would be a tremendously longer period of time running when the REAL data is added. Again there will be about 14-15 items in the evaluators list and over 120 items per each evaluator in the main list. So that was my only concern. If the time isn't much more that what it is, I don't have any problem with it.

Userlevel 7
Badge +17

speaking of batches, if in this single workflow none of the following actions depend on the previous actions, then why have a commit pending changes in the loop? Move it to the very last action outside of all of the loops. Let SharePoint batch them and take care of them together.

Userlevel 7
Badge +17

The best way to speed this up will be to have less loops. We know that. So the only way I see that happening is if each SAC is a folder and you change the permission on the folder. Thus all items will have the permission of its parent. This will greatly reduce the time if folders can be used to manage the items.

Userlevel 5
Badge +12

Seems your outter for loop takes about 3 minutes now, which each inner loop taking about 36 seconds, so scaling up to your production numbers if all else stays the same, you should see an increase of about 6 minutes, or so the outer loop will take about 9 minutes instead of 3.   I agree with Andrew in limiting the actions that you perform within loops to shave time off of this.

Badge +11

Thanks so much guys!

Reply