The Compare Datasets node compares two snapshots of data and categorizes records into three buckets: new, updated, and unchanged (or deleted).
The Compare Datasets node compares two snapshots of data and categorizes records into three buckets: new, updated, and unchanged (or deleted). This is the foundation of incremental sync workflows that avoid reprocessing the entire dataset on every run.
Real-world example: Every hour, you pull the subscriber list from Mailchimp. You need to detect which subscribers are new (to send a welcome Slack message), which changed their email preferences (to update your CRM), and which unsubscribed (to log the churn).
Workflow structure:
[Get Current Subscribers] ──────► [Compare Datasets] ──► [New] ──► Slack Welcome
(Mailchimp) ▲ [Updated] ──► CRM Update
│ [Deleted] ──► Churn Log
[Get Previous Snapshot] ────────────────┘
(Database)
```text
Configure the Compare Datasets node:
| Setting | Value |
|----------------------------|----------------------------------|
| Input A (current data) | Connected to Mailchimp node |
| Input B (previous data) | Connected to Database node |
| Fields to Match | `email` |
| Fields to Compare | `status`, `preferences` |
The node produces three output branches:
```json
// Output 1 — New items (in A but not in B):
{ "email": "newuser@example.com", "status": "subscribed", "name": "New User" }
// Output 2 — Updated items (in both, but fields differ):
{
"email": "existing@example.com",
"status": "unsubscribed", // changed from "subscribed"
"name": "Existing User"
}
// Output 3 — Unchanged items (in both, fields identical):
{ "email": "stable@example.com", "status": "subscribed", "name": "Stable User" }
```text
> **Tip: Save the Snapshot**
>
> After comparison, upsert the current dataset into your snapshot table so the next run compares against fresh data. Use `ON CONFLICT (email) DO UPDATE` in Postgres or equivalent.
This pattern reduces API calls, prevents duplicate notifications, and gives you audit-ready change tracking.
**Related:** [Flatten Deeply Nested API Responses](../code-node-mastery/01-flatten-deeply-nested-api-responses.md) | [Use the HTTP Request Node as a Universal Connector](../integration-patterns/01-use-the-http-request-node-as-a-universal-connector.md)
I build production n8n and Cloudflare automation for teams — the same engineering behind HarperFlow. Fixed-price, escrow-protected, US-based.