forked from digma-ai/otel-sample-app-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
This issue tracks the N+1 query performance problem in the /vets.html endpoint.
Problem:
The current implementation uses EAGER fetching for the Vet-Specialty relationship, causing N+1 queries when loading the vets list. This results in poor performance as each vet requires an additional query to load its specialties.
Solution:
- Changed Vet entity to use LAZY fetching for specialties
- Added @entitygraph and JOIN FETCH to VetRepository methods
- Added an index on vet_specialties(vet_id)
Implementation:
- PR Fix N+1 Query Issue in Vets Endpoint - created-by-agentic #63 contains the code changes
- Modified Vet.java and VetRepository.java
- Added database index
The changes will:
- Eliminate N+1 queries by using a single optimized query
- Improve join performance with the new index
- Maintain backward compatibility
Related:
- PR Fix N+1 Query Issue in Vets Endpoint - created-by-agentic #63 implements the fix