Skip to content

Persist stages in the database

Description

We recently introduced a missing concept of CI stage into our domain model. See app/models/ci/stage.rb. Currently stage is an volatile entity we instantiate by grouping relevant CI/CD statuses/builds by stage name. We also calculate stage status on the fly, using SQL queries.

This leads to the problem of having literally hundreds of queries on pages that display pipeline mini-graphs.

pipeline mini-graph

On pipelines/ despite of using pagination, we sometimes can have 400 SELECT queries, depending of number of stage in pipelines being summarized.

We also have some ongoing work like https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8503 and https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6988 which can benefit from having persisted stages, in terms of performance and code maintainability.

Proposal

Persist Ci::Stage in the database.