Skip to content

perf: backend storage/admin queries without loading all documents (#2) - #54

Open
cornerblue wants to merge 1 commit into
iii123iii:mainfrom
cornerblue:fix/backend-speed-cornerblue
Open

perf: backend storage/admin queries without loading all documents (#2)#54
cornerblue wants to merge 1 commit into
iii123iii:mainfrom
cornerblue:fix/backend-speed-cornerblue

Conversation

@cornerblue

Copy link
Copy Markdown

Summary

Fixes #2 (backend speed).

Quota and admin listing were loading every Document row into memory just to sum sizes. That is O(n) entities per request.

Changes

  1. DocumentRepository.sumSizeBytesByOwnerId + countByOwner_Id aggregate queries
  2. StorageService.store uses sum for storage-limit check
  3. AdminService.getAllUsers uses sum/count per user instead of findByOwnerIdOrderByCreatedAtDesc + stream
  4. Admin seed uses existsByAdminTrue instead of findAll().stream()

Test plan

  • Upload PDF still enforces storage limit
  • Admin user list still shows storage used + document counts
  • ./gradlew test green when Java 21 available

/opire try

Closes #2

…ocuments

- sumSizeBytesByOwnerId for quota checks (store path)
- countByOwner_Id + sum for admin user list (was N+1 load-all-docs)
- existsByAdminTrue / countByAdminTrue instead of findAll().stream()

Closes iii123iii#2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix speed

1 participant