Commit 71f8a6f8 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '321788-fix-n-plus-1s' into 'master'

Fix PipelineController#index N+1

See merge request gitlab-org/gitlab!55053
parents d6b39535 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: []
......
---
title: Fix N+1s related to per-build metadata lookups
merge_request: 55053
author:
type: performance
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment