Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-01-24 14:56:11 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-01-24 14:56:11 +0300
commite73333242ac42a1020319f5d491daf0647af4c54 (patch)
tree6f1b1435205a80c5cee7ca7a43eec7d6c7dd72da /db/post_migrate
parent6714fbad8fc25d3cc6b295d26e3c220987c60fb0 (diff)
Optimize SQL query that removes duplicated stages
Diffstat (limited to 'db/post_migrate')
-rw-r--r--db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb b/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
index 3868e0adae1..c1705cd8757 100644
--- a/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
+++ b/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
@@ -5,10 +5,10 @@ class RemoveRedundantPipelineStages < ActiveRecord::Migration
def up
redundant_stages_ids = <<~SQL
- SELECT id FROM ci_stages a WHERE (
- SELECT COUNT(*) FROM ci_stages b
- WHERE a.pipeline_id = b.pipeline_id AND a.name = b.name
- ) > 1
+ SELECT id FROM ci_stages WHERE (pipeline_id, name) IN (
+ SELECT pipeline_id, name FROM ci_stages
+ GROUP BY pipeline_id, name HAVING COUNT(*) > 1
+ )
SQL
execute <<~SQL