Skip to content

Optimizing merge_request search using latest_mr_diff_id

Max Fan requested to merge 440185-optimize-merge-diff-query into master

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

  1. Enable Feature flag: ::Feature.enable(:update_approval_rules_for_related_mrs)

  2. Enable Coverage-check in settings

  3. Configure .gitlab-ci.yml, set test coverage to 10%, and set job rules to manual

    test:
      script:
        - echo "Hello, World!"
        - echo 'Code coverage 10.0%'
      coverage: '/Code coverage \d+\.\d+/'
      when:
        manual
  4. Trigger a main branch pipeline, do not manually execute the job

  5. Create a new branch feature, increase the test coverage to 20%, create an MR of feature -> main, and execute the feature job manually

  6. You can see that the Coverage-check on the MR page requires approval

  7. Manually execute the pipeline of the main branch. You can see that the Coverage-check no longer requires approval

Related to #440185

Edited by Max Fan

Merge request reports

Loading