Remove self-managed wiki notes
What does this MR do and why?
This MR essentially ports !83391 (merged) (#353381 (closed)) for self-managed customers because the original MR was limited to staging and production. We only had 5 records on GitLab.com, so I don't expect many records for self-managed customers.
Migration details
It will iterate over the notes
table for a self-managed instance and won't do anything on GitLab.com.
$ VERSION=20220601110011 bin/rails db:migrate:up:main
main: == 20220601110011 ScheduleRemoveSelfManagedWikiNotes: migrating ===============
main: -- transaction_open?()
main: -> 0.0000s
main: == 20220601110011 ScheduleRemoveSelfManagedWikiNotes: migrated (0.0353s) ======
$ VERSION=20220601110011 bin/rails db:migrate:down:main
main: == 20220601110011 ScheduleRemoveSelfManagedWikiNotes: reverting ===============
main: == 20220601110011 ScheduleRemoveSelfManagedWikiNotes: reverted (0.0161s) ======
Query plans
SELECT "notes"."id" FROM "notes" WHERE "notes"."id" BETWEEN 1 AND 10000 ORDER BY "notes"."id" ASC LIMIT 1;
Limit (cost=0.57..0.62 rows=1 width=4) (actual time=0.049..0.050 rows=1 loops=1)
Buffers: shared hit=5
I/O Timings: read=0.000 write=0.000
-> Index Only Scan using notes_pkey on public.notes (cost=0.57..400.24 rows=8289 width=4) (actual time=0.047..0.047 rows=1 loops=1)
Index Cond: ((notes.id >= 1) AND (notes.id <= 10000))
Heap Fetches: 0
Buffers: shared hit=5
I/O Timings: read=0.000 write=0.000
Time: 8.617 ms
- planning: 8.525 ms
- execution: 0.092 ms
- I/O read: 0.000 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 5 (~40.00 KiB) from the buffer pool
- reads: 0 from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/10445/commands/37306
SELECT "notes"."id" FROM "notes" WHERE "notes"."id" BETWEEN 1 AND 10000 AND "notes"."id" >= 1 ORDER BY "notes"."id" ASC LIMIT 1 OFFSET 1000;
Limit (cost=51.29..51.34 rows=1 width=4) (actual time=111.737..111.739 rows=1 loops=1)
Buffers: shared hit=370 read=25 dirtied=3
I/O Timings: read=110.593 write=0.000
-> Index Only Scan using notes_pkey on public.notes (cost=0.57..420.96 rows=8289 width=4) (actual time=0.040..111.652 rows=1001 loops=1)
Index Cond: ((notes.id >= 1) AND (notes.id <= 10000) AND (notes.id >= 1))
Heap Fetches: 22
Buffers: shared hit=370 read=25 dirtied=3
I/O Timings: read=110.593 write=0.000
Time: 122.195 ms
- planning: 10.411 ms
- execution: 111.784 ms
- I/O read: 110.593 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 370 (~2.90 MiB) from the buffer pool
- reads: 25 (~200.00 KiB) from the OS file cache, including disk I/O
- dirtied: 3 (~24.00 KiB)
- writes: 0
https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/10446/commands/37309
DELETE FROM "notes" WHERE "notes"."id" BETWEEN 1 AND 10000 AND "notes"."id" >= 1 AND "notes"."id" < 1001 AND "notes"."noteable_type" = 'Wiki';
ModifyTable on public.notes (cost=0.57..714.54 rows=1 width=6) (actual time=136.296..136.297 rows=0 loops=1)
Buffers: shared hit=96 read=65 dirtied=1
I/O Timings: read=135.286 write=0.000
-> Index Scan using notes_pkey on public.notes (cost=0.57..714.54 rows=1 width=6) (actual time=136.292..136.293 rows=0 loops=1)
Index Cond: ((notes.id >= 1) AND (notes.id <= 10000) AND (notes.id >= 1) AND (notes.id < 1001))
Filter: ((notes.noteable_type)::text = 'Wiki'::text)
Rows Removed by Filter: 291
Buffers: shared hit=96 read=65 dirtied=1
I/O Timings: read=135.286 write=0.000
Time: 136.911 ms
- planning: 0.562 ms
- execution: 136.349 ms
- I/O read: 135.286 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 96 (~768.00 KiB) from the buffer pool
- reads: 65 (~520.00 KiB) from the OS file cache, including disk I/O
- dirtied: 1 (~8.00 KiB)
- writes: 0
https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/10445/commands/37308
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #353084 (closed)