Skip to content

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

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

Description

This PR addresses the N+1 query performance issue in the /vets.html endpoint by implementing the following changes:

  1. Changed FetchType.EAGER to FetchType.LAZY in the Vet entity
  2. Added @NamedEntityGraph to optimize loading of specialties
  3. Added necessary database indexes on vet_specialties.vet_id and specialties.id

Changes Made

  1. Modified Vet.java:

    • Changed fetch type to LAZY
    • Added NamedEntityGraph for specialties
  2. Added new database indexes in indexes.sql:

    • Created index on vet_specialties(vet_id)
    • Created index on specialties(id)

Testing

The changes have been tested locally and show significant improvement in query performance by reducing the number of database queries executed when loading vets and their specialties.

Related Issues

Fixes #83

Expected Outcome

  • Reduced number of database queries when loading vets and their specialties
  • Improved response time for the /vets.html endpoint
  • Better overall application performance

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.

Fix N+1 Query in Vets Endpoint-created-by-agentic
1 participant