Skip to content

Implement N+1 query prevention add batching and eager-loading where missing #911

Description

@nanaf6203-bit

Problem

Several N+1 query patterns exist: SessionsService filters sessions in-memory, DashboardService loads recommendations with loops, NotificationsService loads preferences separately.

Expected Outcome

Zero N+1 query patterns in the codebase.

Acceptance Criteria

  • Audit all services for N+1 patterns
  • Fix each pattern: use include, batch requests, or cache results
  • Add automated detection via Prisma event logging

Files Affected

src/sessions/sessions.service.ts, src/dashboard/dashboard.service.ts, src/notifications/notifications.service.ts

Difficulty

Medium

Estimated Effort

Medium (1 week)

Labels

performance, database, refactoring

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions