diff options
author | Stan Hu <stanhu@gmail.com> | 2019-03-01 10:12:50 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-03-01 10:57:09 -0800 |
commit | a769292c672dea9fae702dd75f643a14752110ee (patch) | |
tree | 779108b3ed100cd47c2f973f49a553d275112df5 /lib/gitlab | |
parent | d86de642d16e0f7518c7f508b5282c89128e9a58 (diff) | |
download | gitlab-ce-a769292c672dea9fae702dd75f643a14752110ee.tar.gz |
Eliminate most N+1 queries loading UserController#calendar_activities
We can reduce a significant number of queries by preloading the
associations for events.
On GitLab.com, for a date that had 456 events, this brought the load
time down from 8.7 to 1.2 s.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/58392
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/contributions_calendar.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb index 5ed6427072a..f7d046600e8 100644 --- a/lib/gitlab/contributions_calendar.rb +++ b/lib/gitlab/contributions_calendar.rb @@ -49,6 +49,7 @@ module Gitlab Event.contributions.where(author_id: contributor.id) .where(created_at: date.beginning_of_day..date.end_of_day) .where(project_id: projects) + .with_associations end # rubocop: enable CodeReuse/ActiveRecord |