Use a better index for environment filtering
When filtering merge requests by an environment name, the index used by DeploymentMergeRequest.deployed_to() is not ideal. We can improve performance by adding the following AND condition: AND environments.project_id = merge_requests.target_project_id This condition forces the query to use the index on merge_requests (project_id, name), instead of using the slower index (name varchar_pattern_ops). See https://gitlab.com/gitlab-org/gitlab/-/issues/270068 for more information.
Showing
Please register or sign in to comment