Article Type: Troubleshooting
Audience: Application Designers, Developers, Solution Architects
Module: Data Flows, Script Editor
Applies to Versions: Fuuz 2025.12+
As industrial operations scale, applications must process increasingly large datasets for analytics, reporting, and operational intelligence. Developers often encounter performance concerns when transitioning from small test datasets to production-scale data volumes. This article demonstrates how properly optimized transforms scale efficiently with the Fuuz Data Flow engine, and provides guidance on handling datasets ranging from thousands to tens of thousands of records.
The following benchmarks compare transform performance across two real-world datasets using a workcenter history aggregation that performs complex grouping, duration calculations, and multi-dimensional analytics.
| Attribute | Small Dataset | Medium Dataset | Scale Factor |
|---|---|---|---|
| Total Records | 2,343 | 14,368 | 6.1x |
| Workcenters | 5 | 20 | 4x |
| Time Period | 1 month | 3 months | 3x |
| Payload Size | ~2.2 MB | ~13 MB | 6x |
| Output Days | 30 | 92 | 3x |
| Output Weeks | 5 | 14 | 2.8x |
| Implementation | Small (2.3K) | Medium (14.4K) | Actual Increase | Scaling Efficiency |
|---|---|---|---|---|
| JSONata (Original) | ~70 seconds | Not practical* | — | Poor (O(n²)) |
| JSONata (Optimized) | ~19 seconds | ~2+ minutes* | ~6x+ | Fair (O(n)) |
| JavaScript (Optimized) | ~1-3 seconds | ~3 seconds | ~1-2x | Excellent (O(n)) |
* Estimated based on algorithmic complexity; not tested due to impractical execution times.
Transform performance scaling depends on algorithmic complexity. Understanding these patterns helps predict how transforms will behave as data volumes grow.
| Factor | JSONata | JavaScript |
|---|---|---|
| Execution Model | Interpreted expression language | JIT-compiled V8 engine |
| Array Operations | Functional, creates intermediates | Native, highly optimized |
| Sort Algorithm | Standard implementation | Timsort with adaptive optimization |
| Object Creation | Creates new objects per operation | Mutable accumulators, in-place updates |
| Hash Lookup | Object property access | O(1) hash maps with inline caching |
The optimized JavaScript implementation achieves O(n log n) complexity—the sort operation is O(n log n), but all subsequent processing is O(n) single-pass. This explains why 6x more data results in only ~2x more time rather than 6x or 36x.
The Fuuz Data Flow Designer provides a visual environment for building and testing transforms with large datasets. JavaScript Transform nodes leverage the full power of the V8 engine for maximum performance.
[SCREENSHOT PLACEHOLDER: Data Flow Designer showing Source Node connected to JavaScript Transform Node with the large dataset aggregation flow]
Within the JavaScript Transform node, access input data via the $ variable. The transform function should return the processed result object.
// Access input data from the connected source node
const records = $.workcenterHistory;
// Perform optimized single-pass aggregation
const sorted = records.slice().sort((a, b) => {
if (a.workcenterId < b.workcenterId) return -1;
if (a.workcenterId > b.workcenterId) return 1;
if (a.occurAt < b.occurAt) return -1;
if (a.occurAt > b.occurAt) return 1;
return 0;
});
// Build all aggregations in single pass
// ... (see full optimized script)
return {
summary: { /* aggregated results */ },
aggregations: { byMonth, byWeek, byDay }
};
[SCREENSHOT PLACEHOLDER: JavaScript Transform Node editor showing the optimized aggregation function code]
The Fuuz Script Editor provides an interactive environment for developing and testing transforms before deploying them to Data Flows. Both JSONata and JavaScript transforms can be tested with real payload data.
[SCREENSHOT PLACEHOLDER: Script Editor interface showing JavaScript mode selected, with payload data in input panel and transform function in script panel]
Apply these techniques to ensure transforms scale efficiently with data volume:
Build all groupings (by month, week, day, workcenter) in a single loop instead of multiple separate passes:
// EFFICIENT: Single pass builds all aggregations
for (let i = 0; i < records.length; i++) {
const rec = records[i];
// Update month aggregation
if (!byMonthMap[rec.month]) byMonthMap[rec.month] = initAccumulator();
byMonthMap[rec.month].total += rec.duration;
// Update week aggregation (same loop)
if (!byWeekMap[rec.yearWeek]) byWeekMap[rec.yearWeek] = initAccumulator();
byWeekMap[rec.yearWeek].total += rec.duration;
// Update day aggregation (same loop)
if (!byDayMap[rec.day]) byDayMap[rec.day] = initAccumulator();
byDayMap[rec.day].total += rec.duration;
}
Never filter inside a loop—this creates O(n²) complexity:
// BAD - O(n²): Filters entire array for each record
records.forEach(rec => {
const related = records.filter(r => r.workcenterId === rec.workcenterId);
});
// GOOD - O(n): Pre-group, then process
const byWorkcenter = {};
records.forEach(rec => {
if (!byWorkcenter[rec.workcenterId]) byWorkcenter[rec.workcenterId] = [];
byWorkcenter[rec.workcenterId].push(rec);
});
Replace localeCompare() with direct comparison operators for 2-3x faster sorting:
// SLOWER
records.sort((a, b) => a.occurAt.localeCompare(b.occurAt));
// FASTER (ISO date strings compare correctly with < >)
records.sort((a, b) => {
if (a.occurAt < b.occurAt) return -1;
if (a.occurAt > b.occurAt) return 1;
return 0;
});
Avoid recomputing the same values repeatedly:
// Cache year boundaries for week calculation
const jan1Cache = {};
function getJan1Ms(year) {
if (!jan1Cache[year]) {
jan1Cache[year] = Date.UTC(year, 0, 1);
}
return jan1Cache[year];
}
Use these guidelines to plan for production workloads:
| Record Count | Expected Time (JS) | Recommended Approach |
|---|---|---|
| < 1,000 | < 1 second | JSONata or JavaScript |
| 1,000 - 5,000 | 1-2 seconds | JavaScript recommended |
| 5,000 - 20,000 | 2-4 seconds | JavaScript required |
| 20,000 - 100,000 | 5-15 seconds | JavaScript + consider pre-aggregation |
| > 100,000 | 15+ seconds | Pre-aggregate at database level or batch |
Contact Fuuz Support if:
| Version | Date | Editor | Description |
|---|---|---|---|
| 1.0 | 2026-01-01 | Craig Scott | Initial Release - Large dataset management and Data Flow performance optimization |