Add constraints to spam_logs.user_id with NOT VALID
What does this MR do and why?
This change adds a NOT NULL constraint to the spam_logs.user_id column and removes records that refer to a non-existent user_id.
DELETE FROM "spam_logs"
WHERE (spam_logs.id) IN (
SELECT spam_logs.id
FROM "spam_logs"
LEFT OUTER JOIN users ON spam_logs.user_id = users.id
WHERE spam_logs.id >= 1
AND spam_logs.id < 501
AND users.id IS NULL
);
Time: 58.861 ms
- planning: 2.562 ms
- execution: 56.299 ms
- I/O read: 54.627 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 1863 (~14.60 MiB) from the buffer pool
- reads: 68 (~544.00 KiB) from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
https://console.postgres.ai/gitlab/gitlab-production-main/sessions/45810/commands/140235
References
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by mo khan