/events/past: 33 queries and ~466ms median per render
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 58/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- rails, ruby
- 领域
- backend, performance
调研方向
首先重新测量 GET /events/past,并通过 paginated_events、load_events、fetch_past_events、EventPresenter.decorate_collection 和 EventCardComponent.with_collection 跟踪 EventsController#past。捕获装饰和渲染期间的查询,然后验证查询数量和中位耗时有所改善,同时 UNION 顺序和 ETag 行为保持不变;将结果与 #2888 进行比较。
由索引模型根据 Issue 内容生成。
描述
Summary
GET /events/past (EventsController#past) takes a median 466ms per render (max 17.3s) and issues 33 queries (median db_runtime 80ms, view_runtime 118ms). 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_past_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)
33 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: 127 requests, median 466ms, max 17.3s. Stale by the time you read this — re-measure before starting.
Suggested directions
- Capture the 33 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
- #2888 — the sibling
/events/upcomingaction, same code path; share findings - #2885 — same measurement window
- 主要语言
- Ruby
- 星标
- 104
- 派生
- 205
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 67
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
codebar/planner 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 4/5 3-5 天 新手友好度 48/100
-
难度 5/5 一周以上 新手友好度 25/100
-
难度 5/5 一周以上 新手友好度 35/100
-
good first issue performance
难度 3/5 1-2 天 新手友好度 78/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
simp/pupmod-simp-simp#395 ·
-
难度 2/5 1-3 小时 新手友好度 80/100
simp/pupmod-simp-rsyslog#219 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
simp/pupmod-simp-pupmod#256 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
simp/pupmod-simp-sudo#150 ·
-
难度 1/5 1 小时以内 新手友好度 90/100