Skip to content

Fix N+1 Query Performance Issue in Vets Endpoint-created-by-agentic #86

@shaykeren

Description

@shaykeren

The Vets endpoint (/vets.html) is experiencing an N+1 query performance issue due to eager loading of specialties for each vet.

Problem:

  • The Vet entity uses EAGER fetching for the specialties relationship
  • This causes a separate query for each vet's specialties
  • No database indexes on the join table columns

Solution:

  1. Changed fetch type to LAZY with @batchsize optimization
  2. Added @entitygraph for efficient loading
  3. Added database indexes on:
    • vet_specialties.vet_id
    • vet_specialties.specialty_id
    • specialties.id

Related PR: #85

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions