Parent Child - how to update parent after updating all children?

Describe the problem/error/question

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?

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

hello @AnotherUserName

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

2 Likes

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.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.