/events/past: 33 queries and ~466ms median per render
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 58/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rails, ruby
- Lĩnh vực
- backend, performance
Hướng nghiên cứu
Bắt đầu bằng cách đo lại GET /events/past và lần theo EventsController#past qua paginated_events, load_events, fetch_past_events, EventPresenter.decorate_collection và EventCardComponent.with_collection. Ghi lại các truy vấn trong quá trình decoration và rendering, sau đó xác minh rằng số lượng truy vấn và thời lượng trung vị được cải thiện, trong khi thứ tự UNION và hành vi của ETag vẫn không thay đổi; so sánh các phát hiện với #2888.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Ruby
- Star
- 104
- Fork
- 205
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 67
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của codebar/planner
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Clean up historical duplicate invitation rows (one member, two invitations per event/workshop) Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
good first issue performance
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 78/100
Tất cả issue của codebar/planner
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Please Drop ruby 3.2 support Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
googleapis/google-api-ruby-client#28001 · 5 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100