Tips > Data, APIs & Webhooks

Use Compare Datasets to Detect New, Updated, and Deleted Records

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)

Showcase builds

19 complete workflows from my own projects, each with its n8n workflow JSON to import. Showcase entries link the file at the end of the article.

See the showcase builds

Keep reading

191 entries grouped by topic, from first workflow to queue mode. Free, no signup.

Browse the encyclopedia

Need it built?

I design, build and run n8n systems for clients. Every engagement starts with a $1,500 diagnostic audit, credited toward the build.

Book a 20-minute call