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 uses FetchType.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 to FetchType.LAZY in the Vet entity
- Added
JOIN FETCH query in VetRepository for efficient loading
- Added
@EntityGraph for paginated queries
- Added database indexes on
vet_id and specialty_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
Related Links
Issue Description
The
/vets.htmlendpoint is experiencing performance issues due to N+1 query patterns when loading veterinarians and their specialties.Root Cause
Vetentity usesFetchType.EAGERfor the specialties relationship, causing unnecessary database queriesSolution
A pull request (#92) has been created with the following changes:
FetchType.EAGERtoFetchType.LAZYin theVetentityJOIN FETCHquery inVetRepositoryfor efficient loading@EntityGraphfor paginated queriesvet_idandspecialty_idcolumnsExpected Outcome
/vets.htmlendpointMonitoring
After implementing these changes, we should monitor:
/vets.htmlendpointRelated Links