Constrain environment deployments to project IDs
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:
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?
-
Changelog entry added, if necessary - Review
-
Has been reviewed by Backend -
Has been reviewed by Database
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Squashed related commits together