Refactor archived scopes to use ancestor-aware queries

What does this MR do and why?

Replace direct archived and non_archived scope implementations with their ancestor-aware counterparts self_or_ancestors_archived and self_and_ancestors_non_archived. This ensures that when a group is archived, all of its descendant groups are correctly treated as archived, maintaining proper hierarchical archive state inheritance.

References

Query plans

Since we're changing the scopes, many queries will be affected; therefore, we're using a feature flag. Here are a few query plans:

Before After
https://console.postgres.ai/gitlab/gitlab-production-main/sessions/45651/commands/139896 https://console.postgres.ai/gitlab/gitlab-production-main/sessions/45651/commands/139899
https://console.postgres.ai/gitlab/gitlab-production-main/sessions/45651/commands/139897 https://console.postgres.ai/gitlab/gitlab-production-main/sessions/45651/commands/139898

How to set up and validate locally

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.

Related to #579246

Edited by Abdul Wadood

Merge request reports

Loading