Commit dce09398 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Omit WHERE clause for NOT labels filter when empty

This clause will always be true when the labels provided are
non-existent. In certain cases, having this SQL clause results in
PG picking a slow query plan.

Changelog: performance
parent a5871b52
......@@ -82,6 +82,8 @@ module Issuables
if root_namespace
label_ids = find_label_ids(label_names).flatten(1)
return issuables if label_ids.empty?
issuables.where(label_link_query(target_model, label_ids: label_ids).arel.exists.not)
else
issuables.where(label_link_query(target_model, label_names: label_names).arel.exists.not)
......
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