Project

General

Profile

Actions

Task #7

open

StatisticsService streams entire tables through memory

Added by Redmine Admin about 2 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Start date:
04/27/2026
Due date:
% Done:

0%

Estimated time:

Description

Where: src/main/kotlin/com/articon/base/domain/analytics/statistics/common/services/StatisticsService.kt

  • ~20 findAll() calls (lines 72, 100, 126, 201, …) over orders, workers, deliveries, invoices, worker rewards.

What's wrong: The service materializes whole tables into the JVM heap, then filters and aggregates in Kotlin. No pagination, projection, or DB-side aggregation.

Why it matters: Latency and heap footprint scale linearly with table size. Once any of those tables grows into the millions of rows, analytics endpoints OOM the JVM (4 GB heap per gradle.properties) or stall on network/serialization. Read-replica unfriendly.

Suggested fix: Push filters/aggregates into SQL (COUNT/SUM/GROUP BY); add date-range filters at the query layer; consider a materialized stats table refreshed by the existing stats-heartbeat daemon.

No data to display

Actions

Also available in: Atom PDF