Skip to content

chore(optimization): remove n+1 query from invoices controller #3827

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

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

murparreira
Copy link
Contributor

Context

We’ve been seeing Sentry EU alerts related to N+1 queries when serializing invoices.
This PR addresses one of those issues:
Sentry Issue #44595609

Description

Updated the render call to eager load additional associations for invoices.
This change ensures that billing_entity and applied_usage_thresholds are preloaded when rendering the collection.

@murparreira murparreira requested a review from annvelents June 13, 2025 01:45
@murparreira murparreira merged commit abdc13a into main Jun 13, 2025
14 checks passed
@murparreira murparreira deleted the chore/fix-n-1-query-on-invoices-controller branch June 13, 2025 13:10
diegocharles pushed a commit that referenced this pull request Jul 11, 2025
## Context

We’ve been seeing Sentry EU alerts related to N+1 queries when
serializing invoices.
This PR addresses one of those issues:
[Sentry Issue
#44595609](https://lago-eu.sentry.io/issues/44595609/?project=4508291321233488&query=is%3Aunresolved&referrer=issue-stream&stream_index=3)

## Description

Updated the render call to eager load additional associations for
invoices.
This change ensures that billing_entity and applied_usage_thresholds are
preloaded when rendering the collection.
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.

2 participants