Skip to content

Fix N+1 Query Performance Issue in /vets.html Endpoint - created-by-agentic #64

@shaykeren

Description

@shaykeren

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:

  1. Changed Vet entity to use LAZY fetching for specialties
  2. Added @entitygraph and JOIN FETCH to VetRepository methods
  3. Added an index on vet_specialties(vet_id)

Implementation:

The changes will:

  • Eliminate N+1 queries by using a single optimized query
  • Improve join performance with the new index
  • Maintain backward compatibility

Related:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions