Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

shaykeren
Copy link

This PR addresses the N+1 query performance issue in the Vets endpoint by implementing the following changes:

  1. Changed FetchType from EAGER to LAZY for specialties in Vet entity
  2. Added NamedEntityGraph for efficient fetching of Vet specialties
  3. Updated VetRepository to use EntityGraph annotation
  4. Added composite index on vet_specialties table for improved query performance

These changes will:

  • Prevent unnecessary queries when specialties are not needed
  • Optimize fetching when specialties are needed using join fetch
  • Improve query performance with proper indexing

Testing:

  • The changes maintain existing functionality while improving performance
  • The EntityGraph ensures efficient loading of specialties when needed
  • The composite index will improve join performance

Related Issue: #e8efc2b4-5f5e-11f0-bbd9-0242ac160009

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant