Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2fb0ebf3
Commit
2fb0ebf3
authored
May 31, 2019
by
Alexandru Croitor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preload labels in EpicsController#index
Preload labels in EpicsController#index to avoid N+1 queries.
parent
1a015af5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
1 deletion
+26
-1
ee/app/controllers/groups/epics_controller.rb
ee/app/controllers/groups/epics_controller.rb
+1
-1
ee/changelogs/unreleased/ee-11178-fix-n1-queries-in-epics-controller-index.yml
...sed/ee-11178-fix-n1-queries-in-epics-controller-index.yml
+5
-0
ee/spec/controllers/groups/epics_controller_spec.rb
ee/spec/controllers/groups/epics_controller_spec.rb
+20
-0
No files found.
ee/app/controllers/groups/epics_controller.rb
View file @
2fb0ebf3
...
...
@@ -99,7 +99,7 @@ class Groups::EpicsController < Groups::ApplicationController
end
def
preload_for_collection
@preload_for_collection
||=
[
:group
,
:author
]
@preload_for_collection
||=
[
:group
,
:author
,
:labels
]
end
def
authorize_create_epic!
...
...
ee/changelogs/unreleased/ee-11178-fix-n1-queries-in-epics-controller-index.yml
0 → 100644
View file @
2fb0ebf3
---
title
:
Performance improvement when loading epics list
merge_request
:
13904
author
:
type
:
performance
ee/spec/controllers/groups/epics_controller_spec.rb
View file @
2fb0ebf3
...
...
@@ -116,6 +116,26 @@ describe Groups::EpicsController do
end
end
context
"when epic has multiple labels"
do
render_views
let
(
:label
)
{
create
(
:label
)
}
let!
(
:labeled_epic
)
{
create
(
:labeled_epic
,
group:
group
,
labels:
[
label
])
}
it
'does not cause N+1 queries'
do
get
:index
,
params:
{
group_id:
group
}
control_count
=
ActiveRecord
::
QueryRecorder
.
new
do
get
:index
,
params:
{
group_id:
group
}
end
label
=
create
(
:label
)
create
(
:labeled_epic
,
group:
group
,
labels:
[
label
])
expect
{
get
:index
,
params:
{
group_id:
group
}
}.
not_to
exceed_query_limit
(
control_count
)
end
end
context
'when format is JSON'
do
before
do
allow
(
Kaminari
.
config
).
to
receive
(
:default_per_page
).
and_return
(
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment