Cause of 140+ WU recursive loop

I was running a recursive WF with a much higher WU cost that expected. 140+ per loop.

The set up:

  • doing an update on all products in system (5000+)

  • Sent all products to loop

  • Made one update to each product (each successful action cost 0.6 WU).

Was it sending the 5000+ products to each loop that caused the WU to be so high?

Good question… Hmm. Maybe because you are sending the whole list of products and not just one at a time? I’m not sure why it would be so expensive if it’s just passing that along. Maybe try passing just unique ids as a list of text instead of the product object to see if that might reduce it? :man_shrugging:

I was thinking that as well, but then I’d need to ‘Do a search for’ for each of the UIDs, which I presume would also be expensive ( I thought it would be significantly more expensive than just passing all the products directly in the loop).

Yeah, I’m not sure. I remember someone a while ago doing tests to see what would cost more WU for certain things, but I can’t remember who it was. :blush:

Yes, don’t do this. Why not just schedule API workflow on a list of all items?

They only negative is that there is no way to tell its completed yet in Bubble with Schedule Workflow on a List.

I thought doing a workflow on a list was a big no-no whenever the list was greater than 100.

I always defaulted to doing a recursive workflow because of this.

In the past, sure, but like 2 years ago they made schedule API workflow on a list performant on up to 100,000 items.

Yep needs a jenky workaround every single time…

I learn something new everyday.

If workflow on a list is actually performant now, is there any core use case for recursive?

Rare case for looping. I’ve move all my recursive to schedule on a list and saved an average of 80% on WU for that. The only case I can see would be related to racing issue with nested data and delay between scheduled item couldn’t not avoid.

Every thing you send in will be fetched each time it’s in the list, that’s why it’s expensive. Instead, you send unique ids as list, on each loop do search for current ID as constraint so it’s an individual data request which is only 0.015 per item, so each loop is action cost 0.5 plus individual item fetch of 0.015 plus running of data manipulation of 0.6, so around 1.17 per loop.

Compare the above method to schedule on list. Schedule on list may be cheaper if bubble doesn’t charge the scheduler fee of 0.1 per backend workflow scheduled.

To avoid the 0.1 backend workflow scheduled fee, just use your app API to loop through instead of doing 5,000 items is something you’ll do often…if not, don’t bother.