Meeting show pages run 63-93 queries per request (attendee N+1)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 领域
- backend, performance
调研方向
从 MeetingsController#show 和 app/views/meetings/show.html.haml 开始,追踪与会者及其成员的加载和渲染方式。在进行更改之前,从 Codebar requests dashboard 重新测量当前的查询数量。完成的标准是 show 页面渲染结果完全一致,并且其 queries_count p50 从报告的约 63 降至个位数。
由索引模型根据 Issue 内容生成。
描述
Summary
MeetingsController#show runs 63 queries per request (median), 93 at p95 for a page with ~60 attendees — a classic N+1. Only 412 requests in the last 7 days so this is small in aggregate (1.6% of allocations), but the per-request cost is the worst query-count in the app and cheap to fix.
Measured
7-day window 2026-09-21..27 (canonical logs): 412 requests, allocations p50 25,679, queries_count p50 63, p95 93. Re-measure from current logs before starting.
The loop in app/views/meetings/show.html.haml touches attendee.member.avatar(56) and attendee.member.full_name per row, and @attendees is built without preloading:
@attendees = @meeting.invitations.where(attending: true)
each attendee then triggers a members lookup (plus whatever avatar loading costs).
Suggested directions
- Preload members:
@meeting.invitations.where(attending: true).includes(:member) - Check
members/organisers_gridfor the same pattern on@meeting.organisers - While there:
sanitize(@meeting.description)runs per render — cache the fragment or sanitize on write (same treatment as #2951)
Verify
queries_count p50 for MeetingsController#show drops from ~63 to single digits on the Codebar requests dashboard; page renders identically.
Related: #2951, #2952 (same measurement method)
- 主要语言
- Ruby
- 星标
- 104
- 派生
- 205
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 81
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
codebar/planner 的其他 Issue
-
good first issue tech debt
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
good first issue refactoring tech debt
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
good first issue tech debt
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
Chapter show pages allocate ~21k+ objects per render for large chapters (18% of app allocations)未关闭performance
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
相似的 Issue
-
area/web interface
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
chef/mixlib-shellout#287 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复