diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-02-16 21:08:47 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-02-20 15:57:03 +0800 |
commit | d38fb942e188021d7def5eb577a73c82b8e5e66d (patch) | |
tree | 56a98b17c36de5914fcbac959e7b0fc1c0b009a3 | |
parent | 12cd4c83604e43dc308ba13fa3d5a6571409c1f8 (diff) | |
download | gitlab-ce-d38fb942e188021d7def5eb577a73c82b8e5e66d.tar.gz |
Optimize Ci::Pipeline.latest query
Since we already know which ref we want, we could filter it out first.
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/issues/26570#note_23423376
Closes #26570
-rw-r--r-- | app/models/ci/pipeline.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index dc4590a9923..2a987bfa87b 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -91,6 +91,7 @@ module Ci scope :latest, ->(ref = nil) do max_id = unscope(:select) .select("max(#{quoted_table_name}.id)") + .where(ref: ref) .group(:ref, :sha) relation = ref ? where(ref: ref) : self |