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
7aee7a9e
Commit
7aee7a9e
authored
Aug 27, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
a8596848
f91b5d58
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
app/controllers/dashboard/projects_controller.rb
app/controllers/dashboard/projects_controller.rb
+1
-0
changelogs/unreleased/sh-project-feature-nplus-one.yml
changelogs/unreleased/sh-project-feature-nplus-one.yml
+5
-0
spec/features/dashboard/projects_spec.rb
spec/features/dashboard/projects_spec.rb
+22
-0
No files found.
app/controllers/dashboard/projects_controller.rb
View file @
7aee7a9e
...
...
@@ -70,6 +70,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
.
new
(
params:
finder_params
,
current_user:
current_user
)
.
execute
.
includes
(
:route
,
:creator
,
:group
,
namespace:
[
:route
,
:owner
])
.
preload
(
:project_feature
)
.
page
(
finder_params
[
:page
])
prepare_projects_for_rendering
(
projects
)
...
...
changelogs/unreleased/sh-project-feature-nplus-one.yml
0 → 100644
View file @
7aee7a9e
---
title
:
Remove N+1 SQL query loading project feature in dashboard
merge_request
:
32169
author
:
type
:
performance
spec/features/dashboard/projects_spec.rb
View file @
7aee7a9e
...
...
@@ -220,4 +220,26 @@ describe 'Dashboard Projects' do
expect
(
find
(
'input#merge_request_target_branch'
,
visible:
false
).
value
).
to
eq
'master'
end
end
it
'avoids an N+1 query in dashboard index'
do
create
(
:ci_pipeline
,
:with_job
,
status: :success
,
project:
project
,
ref:
project
.
default_branch
,
sha:
project
.
commit
.
sha
)
visit
dashboard_projects_path
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
visit
dashboard_projects_path
}.
count
new_project
=
create
(
:project
,
:repository
,
name:
'new project'
)
create
(
:ci_pipeline
,
:with_job
,
status: :success
,
project:
new_project
,
ref:
new_project
.
commit
.
sha
)
new_project
.
add_developer
(
user
)
ActiveRecord
::
QueryRecorder
.
new
{
visit
dashboard_projects_path
}.
count
# There are three known N+1 queries:
# 1. Project#open_issues_count
# 2. Project#open_merge_requests_count
# 3. Project#forks_count
#
# In addition, ProjectsHelper#load_pipeline_status also adds an
# additional query.
expect
{
visit
dashboard_projects_path
}.
not_to
exceed_query_limit
(
control_count
+
4
)
end
end
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