Skip to content
Snippets Groups Projects
Commit d38fb942 authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

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
parent 12cd4c83
No related branches found
No related tags found
1 merge request!9306Optimize Ci::Pipeline.latest query
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment