• Yorick Peterse's avatar
    Use a better index for environment filtering · 0d8cc401
    Yorick Peterse authored
    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.
    0d8cc401
deployment_merge_request.rb 953 Bytes