forked from digma-ai/forkof-spring-petclinic
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
Issue Description
A severe performance degradation has been detected in the activity logs query system due to an N+1 query pattern.
Current Behavior
- Query duration: 2.72 seconds (normal: 3.09 milliseconds)
- Query is being executed 82 times per request in 41% of requests
- Endpoint:
/api/clinic-activity/query-logs - Criticality: 0.87
Root Cause
The current implementation executes the same query multiple times in a loop instead of using a single optimized query. This N+1 query pattern is causing significant performance overhead.
Impact
- Severely degraded response times (2.72s vs expected 3.09ms)
- Increased database load
- Poor user experience
- Resource inefficiency
Solution
A PR has been created (#72) that implements the following fixes:
- Replace multiple individual queries with a single optimized query
- Implement pagination to limit result set size
- Add proper response structure with pagination metadata
- Add OpenTelemetry instrumentation for better observability
Expected Improvement
- Query duration reduction from 2.72s to ~10ms
- Elimination of N+1 query pattern
- Reduced database load
- Better resource utilization