I’m replicating records into a database. I have a flow that grabs parent records from the database, and then uses a REST API to retrieve child records. When all children are retreived and put into the database, I want to mark the parents as processed.
This flow snippet is working, but I’m updating each parent once for each child, so it takes longer to execute that step than is strictly necessary. Is there a simple way to only update the parent once after the children have been updated?
you can split the workflow into two parts. Main part - get list of parent records and process them one-by-one in the sub workflow.
in sub workflow get the list of child records, update them in the table and exit.
Example workflows. Parent:
Sub. Take a note on the last node. it has a custom setting enabled (Execute Once). We need that to be sure that the workflow process all items and return only one result
Thank you, @barn4k ! That resolved my issue, and it also helped with a following issue.
I was batching a huge amount of data to back process a few years of transactions. The n8n instance was running out of RAM. Throwing my sub processes into a sub process also helped with the execution speed and memory use.