Commit e7333324 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Optimize SQL query that removes duplicated stages

parent 6714fbad
...@@ -5,10 +5,10 @@ class RemoveRedundantPipelineStages < ActiveRecord::Migration ...@@ -5,10 +5,10 @@ class RemoveRedundantPipelineStages < ActiveRecord::Migration
def up def up
redundant_stages_ids = <<~SQL redundant_stages_ids = <<~SQL
SELECT id FROM ci_stages a WHERE ( SELECT id FROM ci_stages WHERE (pipeline_id, name) IN (
SELECT COUNT(*) FROM ci_stages b SELECT pipeline_id, name FROM ci_stages
WHERE a.pipeline_id = b.pipeline_id AND a.name = b.name GROUP BY pipeline_id, name HAVING COUNT(*) > 1
) > 1 )
SQL SQL
execute <<~SQL execute <<~SQL
......
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