Commit 7b82a27e authored by Furkan Ayhan's avatar Furkan Ayhan

Exclude build dependency calculation when creating the pipeline

This will help us to reduce the number of queries for creating
the pipeline.
parent 31f45d7b
...@@ -17,6 +17,7 @@ module Ci ...@@ -17,6 +17,7 @@ module Ci
# Dependencies local to the given pipeline # Dependencies local to the given pipeline
def local def local
return [] if no_local_dependencies_specified? return [] if no_local_dependencies_specified?
return [] unless processable.pipeline_id # we don't have any dependency when creating the pipeline
deps = model_class.where(pipeline_id: processable.pipeline_id).latest deps = model_class.where(pipeline_id: processable.pipeline_id).latest
deps = from_previous_stages(deps) deps = from_previous_stages(deps)
......
---
title: Exclude build dependency calculation when creating the pipeline
merge_request: 59810
author:
type: performance
...@@ -259,15 +259,10 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Seed do ...@@ -259,15 +259,10 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Seed do
def expected_extra_queries def expected_extra_queries
extra_jobs = 2 extra_jobs = 2
non_handled_sql_queries = 3 non_handled_sql_queries = 2
# 1. Ci::Build Load () SELECT "ci_builds".* FROM "ci_builds" # 1. Ci::InstanceVariable Load => `Ci::InstanceVariable#cached_data` => already cached with `fetch_memory_cache`
# WHERE "ci_builds"."type" = 'Ci::Build' # 2. Ci::Variable Load => `Project#ci_variables_for` => already cached with `Gitlab::SafeRequestStore`
# AND "ci_builds"."commit_id" IS NULL
# AND ("ci_builds"."retried" = FALSE OR "ci_builds"."retried" IS NULL)
# AND (stage_idx < 1)
# 2. Ci::InstanceVariable Load => `Ci::InstanceVariable#cached_data` => already cached with `fetch_memory_cache`
# 3. Ci::Variable Load => `Project#ci_variables_for` => already cached with `Gitlab::SafeRequestStore`
extra_jobs * non_handled_sql_queries extra_jobs * non_handled_sql_queries
end end
......
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