Skip to content

Conversation

Oaphi
Copy link
Member

@Oaphi Oaphi commented Aug 28, 2025

This PR ensures we eager load associations used in post lists to avoid N+1 queries when loading category post lists. In particular, it significantly reduces the amount of queries made by generic_share_link (that needs community) and category tag ids getters (that need respective tags).

@Oaphi Oaphi requested a review from ArtOfCode- August 28, 2025 17:24
@Oaphi Oaphi added the area: backend Changes to server-side code label Aug 28, 2025
@Oaphi Oaphi added this to the v0.12.4 milestone Aug 28, 2025
Copy link

codecov bot commented Aug 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.82%. Comparing base (8f93b46) to head (8beb899).
⚠️ Report is 6 commits behind head on develop.

Additional details and impacted files
Components Coverage Δ
controllers 70.87% <100.00%> (+0.02%) ⬆️
helpers 81.92% <ø> (ø)
jobs 60.00% <ø> (ø)
models 86.93% <100.00%> (+0.01%) ⬆️
tasks 61.11% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


# eager loading revived collections' used relation to prevent N+1 queries
@pinned_links = @pinned_links.list_includes
@hot_questions = @hot_questions.list_includes
Copy link
Member Author

@Oaphi Oaphi Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eager loading is done in this manner here to facilitate eager loading of collections received from cache.

@Oaphi Oaphi merged commit c86ab29 into develop Aug 28, 2025
13 checks passed
@Oaphi Oaphi deleted the 0valt/query-optimizations branch August 28, 2025 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: backend Changes to server-side code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants