Data Cloud insights: calculated vs. streaming engine selection
In Salesforce Data Cloud, whether you compute with Calculated Insights (CI) or Streaming Insights (SI) drives your data freshness, your action latency and your operational cost. The two engines solve different architectural problems. Mismatch the engine to the requirement and you get stale segment definitions or excessive credit consumption.
1. Core differences: timing and scope
CI and SI diverge on two points: when the computation executes, and what data it can see while it runs.
Calculated Insights (CI): durable, historical aggregation
Calculated Insights operate across the entire Data Cloud estate, joining Data Model Objects (DMOs), Data Lake Objects (DLOs), Unified Profiles and historical engagement data. They are built for relational, multi-object aggregation over long time horizons, and what comes out is a durable attribute the business can build on.
Typical CI use cases are stable metrics:
- Engagement consistency score: a rolling measure aggregated over weeks or months.
- Cross-channel preference index: a composite score derived from historical interaction records.
- Purchase cadence profile: purchase intervals analyzed across years of data.
CI computations run on a schedule, often daily, rather than in real time. They target the stable attributes that segmentation and scoring models need in order to stay consistent.
A CI emulation example, in Apex:
This pseudo-code aggregates historical order data against Unified Profiles, mirroring what a durable CI calculation does:
// Step 1: Aggregate data from child object (Order__dlm)
List<AggregateResult> orderAggregates = [
SELECT ProfileId__c,
SUM(TotalAmount__c) LifetimeValue,
COUNT(Id) TotalOrders,
MAX(OrderDate__c) LastPurchaseDate
FROM Order__dlm
GROUP BY ProfileId__c
];
// Step 2: Map aggregates by ProfileId
Map<Id, AggregateResult> aggregatesByProfile = new Map<Id, AggregateResult>();
for (AggregateResult ar : orderAggregates) {
aggregatesByProfile.put((Id) ar.get('ProfileId__c'), ar);
}
// Step 3: Query parent Unified Profiles
List<UnifiedProfile__dlm> profiles = [
SELECT Id, Name
FROM UnifiedProfile__dlm
WHERE Id IN :aggregatesByProfile.keySet()
];
// Step 4: Combine and output results (example)
for (UnifiedProfile__dlm profile : profiles) {
AggregateResult ar = aggregatesByProfile.get(profile.Id);
System.debug('Profile: ' + profile.Name);
System.debug('Lifetime Value: ' + ar.get('LifetimeValue'));
System.debug('Total Orders: ' + ar.get('TotalOrders'));
System.debug('Last Purchase Date: ' + ar.get('LastPurchaseDate'));
}
Notes: Order__dlm is the child object mapping to DLOs and DMOs, with a lookup to UnifiedProfile__dlm. The SUM, COUNT and MAX aggregates stand in for the durable metrics a CI generates, typically on a defined schedule.
Streaming Insights (SI): event-driven, windowed evaluation
Streaming Insights evaluate events immediately as they arrive, using rolling or tumbling time windows. They do not scan full historical data. Their scope is restricted to recent activity.
Typical SI use cases are real-time signals:
- Digital behavior events: immediate calculation on web session activity such as page views and session duration.
- Mobile interaction streams: in-app usage events that need a low latency response.
- External telemetry: near-real-time signals ingested from external transactional systems.
An SI example, detecting high-intent users in a 15-minute tumbling window:
The example queries streaming events (the __e object) inside a tight time constraint to find users with heavy recent activity:
// Step 1: Define the time window (15 minutes tumbling window)
Datetime windowEnd = System.now();
Datetime windowStart = windowEnd.addMinutes(-15);
// Step 2: Query Web Engagement Events in the window
List<AggregateResult> recentEvents = [
SELECT UserId,
COUNT(Id) eventCount
FROM WebEngagementEvent__e
WHERE EventType__c = 'ProductView'
AND CreatedDate >= :windowStart
AND CreatedDate <= :windowEnd
GROUP BY UserId
HAVING COUNT(Id) >= 3
];
// Step 3: Process results
for (AggregateResult ar : recentEvents) {
Id userId = (Id) ar.get('UserId');
Integer views = (Integer) ar.get('eventCount');
System.debug('User ' + userId + ' viewed products ' + views + ' times in the last 15 minutes.');
// Trigger real-time actions based on this high-intent signal
}
Notes: the query leans entirely on CreatedDate falling inside the defined boundaries, windowStart to windowEnd. The HAVING clause filters the aggregated results on the windowed count.
2. Side-by-side comparison
| Feature | Calculated Insights (CI) | Streaming Insights (SI) |
|---|---|---|
| Data Scope | Full Data Cloud (Profiles, DMOs, DLOs, historical) | Incoming engagement events only |
| Latency | Scheduled (e.g., hourly, daily) | Seconds to minutes (event-driven) |
| Computation Style | Relational, multi-object, historical joins | Window-based (tumbling/rolling), event-driven |
| Profile Joins | Supported natively | Not supported |
| Primary Usage | Segmentation, durable scoring, baseline metrics | Real-time triggers, immediate alerts, time-sensitive actions |
| Cost Behavior | Predictable, scheduled credit usage | Scales directly with event velocity (continuous consumption) |
One constraint shapes most of the design work: Streaming Insights cannot join Unified Profiles directly, so you have to build around it. Where real-time logic needs a static attribute such as loyalty tier, SI detects the signal and a subsequent Data Action or Flow enriches that signal with pre-calculated CI attributes.
3. Selection criteria: segment vs. trigger
What the metric is for decides the engine.
Choose Calculated Insights for segmentation and definition
Use CI when the requirement is a stable, reusable metric that represents long-term customer state or value. These are the metrics the rest of the customer model rests on.
The rule: if the metric gets referenced repeatedly across audience definitions, reporting or long-term propensity models, it belongs in CI, which is durable and can handle complex relational joins across historical data.
Choose Streaming Insights for immediate action
Use SI when timeliness decides everything and the data's value decays within minutes.
The rule: if the metric drives immediate, time-sensitive engagement or automated decisioning, an abandoned cart being the obvious case, SI is the correct engine, and the higher velocity-dependent credit cost is the price of it.
Leave a Comment