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
53582e21
Commit
53582e21
authored
Feb 26, 2021
by
Matthias Käppler
Committed by
Kamil Trzciński
Feb 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix PipelineController#index N+1
parent
d6b39535
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
2 deletions
+23
-2
app/serializers/pipeline_serializer.rb
app/serializers/pipeline_serializer.rb
+2
-2
changelogs/unreleased/321788-fix-n-plus-1s.yml
changelogs/unreleased/321788-fix-n-plus-1s.yml
+5
-0
spec/serializers/pipeline_serializer_spec.rb
spec/serializers/pipeline_serializer_spec.rb
+16
-0
No files found.
app/serializers/pipeline_serializer.rb
View file @
53582e21
...
...
@@ -43,14 +43,14 @@ class PipelineSerializer < BaseSerializer
:cancelable_statuses
,
:latest_statuses_ordered_by_stage
,
:latest_builds_report_results
,
:manual_actions
,
:retryable_builds
,
:scheduled_actions
,
:stages
,
:latest_statuses
,
:trigger_requests
,
:user
,
{
manual_actions: :metadata
,
scheduled_actions: :metadata
,
downloadable_artifacts:
{
project:
[
:route
,
{
namespace: :route
}],
job:
[]
...
...
changelogs/unreleased/321788-fix-n-plus-1s.yml
0 → 100644
View file @
53582e21
---
title
:
Fix N+1s related to per-build metadata lookups
merge_request
:
55053
author
:
type
:
performance
spec/serializers/pipeline_serializer_spec.rb
View file @
53582e21
...
...
@@ -209,6 +209,22 @@ RSpec.describe PipelineSerializer do
end
end
context
'with scheduled and manual builds'
do
let
(
:ref
)
{
'feature'
}
before
do
create
(
:ci_build
,
:scheduled
,
pipeline:
resource
.
first
)
create
(
:ci_build
,
:scheduled
,
pipeline:
resource
.
second
)
create
(
:ci_build
,
:manual
,
pipeline:
resource
.
first
)
create
(
:ci_build
,
:manual
,
pipeline:
resource
.
second
)
end
it
'sends at most one metadata query for each type of build'
,
:request_store
do
# 1 for the existing failed builds and 2 for the added scheduled and manual builds
expect
{
subject
}.
not_to
exceed_query_limit
(
1
+
2
).
for_query
/SELECT "ci_builds_metadata".*/
end
end
def
create_pipeline
(
status
)
create
(
:ci_empty_pipeline
,
project:
project
,
...
...
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