/events/upcoming: 31 queries and ~467ms median per render
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 104
- Forks
- 205
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 63
Description
Summary
GET /events/upcoming (EventsController#upcoming) takes a median 467ms per render (max 13.7s) and issues 31 queries (median db_runtime 83ms). The action sets an ETag via fresh_when, so conditional requests are cheap, but non-conditional clients (first visit, stale cache, most API clients) pay the full render every time.
The render path:
paginated_eventsruns a UNION ALL across Workshops, Meetings, and Events, counts at the DB level, and returns only the 20 rows for the current pageload_eventsruns threeeager_loadqueries (workshops, meetings, events) for those rowsfetch_upcoming_eventsgroups the rows by date and wraps each in a presenter (EventPresenter.decorate_collection)- The view renders
EventCardComponent.with_collection— each card is fragment-cached (event_card_component/*keys in Solid Cache)
31 queries is well over the handful that steps 1–2 need, so something in decoration or rendering loads associations the current eager loads don't cover.
Measured
3h window on 2026-09-16/17, from production canonical logs: 122 requests, median 467ms, max 13.7s. Stale by the time you read this — re-measure before starting.
Suggested directions
- Capture the 31 queries locally (Bullet or Prosopite against a production dump) and identify the associations touched during decoration and card rendering beyond the current
eager_loadcalls - Add the missing associations to the eager loads or batch them into a single preload, preserving the UNION order
- Check the hit rate on the per-event fragments before adding more caching — they may already absorb most of the view time
Verify
Query count and median duration drop; ETag behaviour unchanged.
Related
- #2887 — the sibling
/events/pastaction, same code path; share findings - #2885 — same measurement window
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at EventsController#upcoming and re-measure the current query count and render time, since the reported production measurements are stale. Trace paginated_events, load_events, fetch_upcoming_events, EventPresenter.decorate_collection, and EventCardComponent with Bullet or Prosopite to identify missing association loads. Done means lower query count and median duration while preserving UNION order and ETag behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- backend, database, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100