diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-10-02 10:14:23 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-10-02 15:31:59 +0200 |
commit | c16b99a49c58161971d1a86613930be439385f02 (patch) | |
tree | efe023f415f4df81b27a8c895b848a71a8c21bff /spec/lib/gitlab/sql | |
parent | 147c46cca195f13ef10ec8fc2db160a833121914 (diff) | |
download | gitlab-ce-c16b99a49c58161971d1a86613930be439385f02.tar.gz |
Use a UNION ALL for getting merge request notesmerge-request-notes-performance
In this particular case the use of UNION ALL leads to a better query
plan compared to using 1 big query that uses an OR statement to combine
different data sources.
See https://gitlab.com/gitlab-org/gitlab-ce/issues/38508 for more
information.
Diffstat (limited to 'spec/lib/gitlab/sql')
-rw-r--r-- | spec/lib/gitlab/sql/union_spec.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sql/union_spec.rb b/spec/lib/gitlab/sql/union_spec.rb index baf8f6644bf..8026fba9f0a 100644 --- a/spec/lib/gitlab/sql/union_spec.rb +++ b/spec/lib/gitlab/sql/union_spec.rb @@ -22,5 +22,12 @@ describe Gitlab::SQL::Union do expect {User.where("users.id IN (#{union.to_sql})").to_a}.not_to raise_error expect(union.to_sql).to eq("#{to_sql(relation_1)}\nUNION\n#{to_sql(relation_2)}") end + + it 'uses UNION ALL when removing duplicates is disabled' do + union = described_class + .new([relation_1, relation_2], remove_duplicates: false) + + expect(union.to_sql).to include('UNION ALL') + end end end |