Commit c04ba78d authored by Patrick Bair's avatar Patrick Bair

Merge branch 'yorick/environments-filtering-performance' into 'master'

Improve performance of filtering merge requests by an environment

See merge request gitlab-org/gitlab!45796
parents e7bc806a 0d8cc401
......@@ -14,7 +14,12 @@ class DeploymentMergeRequest < ApplicationRecord
end
def self.deployed_to(name)
# We filter by project ID again so the query uses the index on
# (project_id, name), instead of using the index on
# (name varchar_pattern_ops). This results in better performance on
# GitLab.com.
where('environments.name = ?', name)
.where('environments.project_id = merge_requests.target_project_id')
end
def self.deployed_after(time)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment