Skip to content

Comments

fix: eager load sponsors and sponsorships in EventsController#2502

Open
mroderick wants to merge 1 commit intocodebar:masterfrom
mroderick:fix/events-sponsors-eager-loading
Open

fix: eager load sponsors and sponsorships in EventsController#2502
mroderick wants to merge 1 commit intocodebar:masterfrom
mroderick:fix/events-sponsors-eager-loading

Conversation

@mroderick
Copy link
Collaborator

Summary

  • Adds :sponsorships to eager loading in Event queries
  • Adds :sponsors to eager loading in Workshop queries
  • Fixes N+1 queries on /events page

Motivation

Bullet was reporting N+1 queries when rendering the events index page. The view calls event.sponsors which requires the sponsorships join table to be eager loaded.

Analysis

  • Before: N+1 query per event for sponsors
  • After: Single query with LEFT OUTER JOIN on sponsorships

Test Plan

  • All existing tests pass
  • Manual verification with Bullet shows no N+1 queries for sponsors

Motivation:
Bullet was reporting N+1 queries when rendering the events index page.
The view calls event.sponsors which requires the sponsorships join table
to be eager loaded.

Analysis:
- Before: N+1 query per event for sponsors
- After: Single query with LEFT OUTER JOIN on sponsorships

This applies to both upcoming and past events queries in the index action.
@mroderick mroderick marked this pull request as ready for review February 21, 2026 15:03
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