Hi I have a question about how every node in n8n behaving when it receives data stream more than one. Let’s say I have a stream of data containing 100 data and I want to do deduplication against the data inside my database and I also want to do deduplication against the data stream itself. There’s 2 scenario that might happen which is every node handling data stream in parallel or every node handling data in sequence and depending on this behavior the nodes flow could be different.
For easier to understand below is the example nodes that I created
This is dummy example and it won’t run.
let’s say that the ‘Data’ node outputting 100 data it means there’s 100 items that goes into ‘Database’ node, my question is how ‘Database’ node behave when it receive 100 items of data?
does it takes one data and check against the database and if it’s new then insert the data to database (sequence scenario) or ‘Database’ node would run all 100 items simulteneuously with 100 items (parallel scenario)
In n8n, nodes process items sequentially rather than in parallel. When your “Data” node outputs 100 items, the “Database” node will iterate through them one by one, completing the entire execution path for the first item before moving on to the second. This means the items do not hit your database simultaneously, but they do follow a strict, step-by-step order.
Because of this behavior, your current workflow has two specific vulnerabilities. First, it does not automatically deduplicate against the stream itself; if two identical items exist in your initial 100-item batch, both will proceed to check the database. Second, a race condition can occur if the second item performs its “existence check” before the first item has finished the “Insert Data” step and committed its changes to the database.
To fix this, you should add a Remove Duplicates node immediately after your data source to clean the stream before it reaches your logic. To ensure absolute data integrity, you should also implement a Unique Constraint on your PostgreSQL table columns. This two-layered approach ensures that your stream is cleaned first and that your database acts as a final, unbreakable safeguard against duplicates.
Short answer: not in parallel. By default n8n runs a node once per item, in order — the next item only reaches the node after the previous one has passed through, so item 50 can never overtake item 1 on the same branch. The exceptions are the nodes that deliberately batch: HTTP Request with batching turned on, a Code node set to Run Once for All Items (it receives the whole array at once), and Execute Sub-Workflow with Wait For Sub-Workflow Completion disabled, which fires and forgets.
That ordering is what decides your two dedup cases. In-stream dedup is cleanest in one Code node in Run Once for All Items mode (build a Set/Map keyed on your field, return only the first hit) or with the Remove Duplicates node’s Remove Items Repeated Within Current Input operation — per-item nodes cannot keep state between items, so a Set + IF combo on the per-item path will not catch duplicates. For the database side, don’t issue one query per item: chunk the 100 items and query once per chunk, or use Remove Duplicates with Remove Items Processed in Previous Executions, which keeps a dedup history between runs so items already seen are dropped without touching the DB at all. If both dedups have to agree on the same view of the data, run the in-stream pass first and the DB pass on the reduced list.
Hi @ezraluandre, the Database node finishes processing the 100 items before is new? and Insert Data run. It doesn’t take item 1 through the whole chain before checking item 2. Two new duplicates can therefore both return false before either gets inserted.
Postgres’s Query Batching controls queries inside that node. The default Single Query sends them together; changing it doesn’t make downstream nodes run between checks.
For check → insert → next item, add Loop Over Items before Database, set Batch Size to 1, and put Database → is new? → Insert Data on its loop output. Connect the insert output and the IF branch for existing records back to Loop Over Items.
That makes each later check see earlier inserts within this execution. The database uniqueness safeguard mentioned above still matters when executions overlap.