Skip to content

Constrain environment deployments to project IDs

yorickpeterse-staging requested to merge ci-environment-status-performance into master

What does this MR do?

This improves the performance of environment/deployment queries dramatically by adding a WHERE project_id = X filter to the has_many :deployments relation of `Environment. See the commit (which contains a lot of details) and https://gitlab.com/gitlab-org/gitlab-ce/issues/36877 for more information. To give an idea:

Performance Improvements Graph

This graph shows the impact of adding an index that simulates the changes made in this MR (I verified that these changes actually produce the same outcome).

This MR also contains a small migration that adds a NOT NULL to environments.project_id. Based on GitLab.com data this column is never NULL and @ayufan mentioned it can't be NULL either.

If possible I would like to have this picked into 10.0 since it's a very small change with a very big impact.

Does this MR meet the acceptance criteria?

Edited by Stan Hu

Merge request reports