forked from digma-ai/otel-sample-app-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Issue Description
The /vets.html
endpoint is experiencing performance issues due to N+1 query patterns when loading veterinarians and their specialties.
Root Cause
- The
Vet
entity usesFetchType.EAGER
for the specialties relationship, causing unnecessary database queries - Missing optimized query to fetch vets with their specialties in a single operation
- Missing database indexes on the join table columns
Solution
A pull request (#92) has been created with the following changes:
- Changed
FetchType.EAGER
toFetchType.LAZY
in theVet
entity - Added
JOIN FETCH
query inVetRepository
for efficient loading - Added
@EntityGraph
for paginated queries - Added database indexes on
vet_id
andspecialty_id
columns - Implemented query result caching
Expected Outcome
- Reduced number of database queries
- Improved response time for the
/vets.html
endpoint - Better database performance with proper indexes
- Efficient caching of frequently accessed data
Monitoring
After implementing these changes, we should monitor:
- Response time of the
/vets.html
endpoint - Number of database queries executed
- Cache hit rates
- Database index usage