Skip to content

Resolve "Clean up after RemoveCommaFromWeightSystemNotes migration"

What does this MR do?

Cleans up from RemoveCommaFromWeightSystemNotes. On GitLab.com, this will do nothing. On other instances, it will migrate any remaining rows inline.

Output from GitLab.com:

gitlabhq_production=> SELECT COUNT(*) FROM notes INNER JOIN system_note_metadata ON notes.id = system_note_metadata.note_id WHERE notes.system AND system_note_metadata.action = 'weight' AND notes.note LIKE '%,';
 count
-------
     0
(1 row)

And query plan:

gitlabhq_production=> EXPLAIN (analyze, buffers) SELECT COUNT(*) FROM notes INNER JOIN system_note_metadata ON notes.id = system_note_metadata.note_id WHERE notes.system AND system_note_metadata.action = 'weight' AND notes.note LIKE '%,';
                                                                QUERY PLAN

---------------------------------------------------------------------------------------------------------------------------------------
---
 Aggregate  (cost=1719862.80..1719862.81 rows=1 width=8) (actual time=6035.217..6035.217 rows=1 loops=1)
   Buffers: shared hit=484920 dirtied=59
   ->  Nested Loop  (cost=0.57..1719862.80 rows=1 width=0) (actual time=6035.199..6035.199 rows=0 loops=1)
         Buffers: shared hit=484920 dirtied=59
         ->  Seq Scan on system_note_metadata  (cost=0.00..1694378.21 rows=7124 width=4) (actual time=1.254..5816.597 rows=36192 loops=
1)
               Filter: ((action)::text = 'weight'::text)
               Rows Removed by Filter: 38309470
               Buffers: shared hit=303721 dirtied=52
         ->  Index Scan using notes_pkey on notes  (cost=0.57..3.57 rows=1 width=4) (actual time=0.006..0.006 rows=0 loops=36192)
               Index Cond: (id = system_note_metadata.note_id)
               Filter: (system AND (note ~~ '%,'::text))
               Rows Removed by Filter: 1
               Buffers: shared hit=181199 dirtied=7
 Planning time: 1.719 ms
 Execution time: 6035.319 ms
(15 rows)

Are there points in the code the reviewer needs to double check?

I didn't add specs because this just reuses the existing class, but I can copy some over if needed.

The initial query would be faster if we added the index, but then we would spend time adding and removing the index, so 🤷

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #6793 (closed).

Edited by Yorick Peterse

Merge request reports