Commit 3205efc1 authored by Krasimir Angelov's avatar Krasimir Angelov

Fix query performance in PipelinesFinder

Add additional `ci_pipelines.project_id = ?` clause that change
the execution to use `index_ci_pipelines_on_project_id_and_id_desc`
instead of `ci_pipelines_pkey` which speeds up the query a lot.

Related to https://gitlab.com/gitlab-org/gitlab/issues/37745.
parent 8240d01a
......@@ -39,7 +39,7 @@ class PipelinesFinder
# rubocop: disable CodeReuse/ActiveRecord
def from_ids(ids)
pipelines.unscoped.where(id: ids)
pipelines.unscoped.where(project_id: project.id, id: ids)
end
# rubocop: enable CodeReuse/ActiveRecord
......
---
title: Fix query performance in PipelinesFinder
merge_request: 21092
author:
type: performance
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