Optimizing merge_request search using latest_mr_diff_id
What does this MR do and why?
Before: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/32831/commands/101199
After: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/32831/commands/101197
\> 50% improvement
This is because of some database magic latest_merge_request_diff_id
on the merge_requests table to skip the Nested Loop Semi Join
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
-
Enable Feature flag:
::Feature.enable(:update_approval_rules_for_related_mrs)
-
Enable Coverage-check in settings
-
Configure
.gitlab-ci.yml
, set test coverage to 10%, and set job rules to manualtest: script: - echo "Hello, World!" - echo 'Code coverage 10.0%' coverage: '/Code coverage \d+\.\d+/' when: manual
-
Trigger a
main
branch pipeline, do not manually execute the job -
Create a new branch
feature
, increase the test coverage to 20%, create an MR of feature -> main, and execute the feature job manually -
You can see that the Coverage-check on the MR page requires approval
-
Manually execute the pipeline of the
main
branch. You can see that the Coverage-check no longer requires approval✨
Related to #440185