Backport of 'Fix Zoekt filter order to avoid performance regression' to 18.8

What does this MR do and why?

This MR backports !219102 (merged) which fixes a critical performance regression in Zoekt code search.

Problem: Placing meta filters (archived) between query_string and scoping filters (repo_ids, traversal_ids) causes Zoekt to scan metadata across all repositories before narrowing down, adding ~1-1.4 seconds of latency to every code search query.

Solution: Reorder filters in CodeQueryBuilder so scoping filters come immediately after query_string, before meta filters.

Performance Impact:

  • Project searches: ~1.8s → ~200ms (90% improvement)
  • Group searches: ~1.7s → ~600ms (65% improvement)

This affects all GitLab instances using Zoekt for code search (currently rolling out to GitLab.com).

Changes:

  • Reordered filters in build_payload method
  • Updated JSON fixtures to match new filter order
  • Added specs to verify filter ordering is maintained

Backport notes for 18.8:

  • Clean cherry-pick from master commit 71743a933cc1
  • No conflicts, all changes applied successfully

Related:

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

  • This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch.
  • The MR that fixed the bug on the default branch has been deployed to GitLab.com (not applicable for documentation or spec changes).
  • The MR title is descriptive (e.g. "Backport of 'title of default branch MR'"). This is important, since the title will be copied to the patch blog post.
  • Required labels have been applied to this merge request
  • This MR has been approved by a maintainer (only one approval is required).
  • Ensure the e2e:test-on-omnibus-ee job has succeeded, or if it has failed, investigate the failures. If you determine the failures are unrelated, you may proceed. If you need assistance investigating, reach out to a Software Engineer in Test in #s_developer_experience.

Note to the merge request author and maintainer

If you have questions about the patch release process, please:

Edited by Dmitry Gruzd

Merge request reports

Loading