Draft: Exclude descendant groups when finding work items for autocomplete
What does this MR do and why?
Related to Show work items with epic type in issues autoco... (#467391)
What: Modify the groups/autocomplete_sources#issue
endpoint to exclude issues in subgroups.
Why: The query for this endpoint timeout for large group hierarchies so we want to test the impact of only returning issues for the groups and its projects. As this is only enabled for work items, the change will be behind the namespace_level_work_items
and work_item_epics
feature flags. Also, these changes don't affect the autocomplete at the project level.
Database
Finder changes
This MR introduces a new param include_group_projects
to WorkItems::WorkItemsFinder
which includes the group's project when the group_id
param is present.
WorkItems::WorkItemsFinder.new(current_user, { group_id: group.id, include_group_projects: true }).execute
- Query plan for a small group hierarchy:
- Query plan for a large group hierarchy:
Endpoint changes
The endpoint for autocomplete issues at the group level groups/autocomplete_sources#issue
changes its query to exclude subgroups
- Previous query
WorkItems::WorkItemsFinder
.new(current_user, { group_id: group.id, state: 'opened', include_descendants: true })
.execute.preload(project: :namespace)
.with_work_item_type
.select(:iid, :title, :project_id, :namespace_id, 'work_item_types.icon_name')
- Query plan for a small group hierarchy: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/29659/commands/92059 (internal only)
- Query plan for a large group hierarchy: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/29659/commands/92071 (internal only)
- New query
WorkItems::WorkItemsFinder
.new(current_user, { group_id: group.id, state: 'opened', include_group_projects: true })
.execute
.preload(project: :namespace)
.with_work_item_type.select(:iid, :title, :project_id, :namespace_id, 'work_item_types.icon_name')
- Query plan for a small group hierarchy:
- Query plan for a large group hierarchy:
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
Before | After |
---|---|
How to set up and validate locally
- Enable the feature flag
Feature.enable(:work_item_epics)
- Create a group with a subgroup and a project in each
- Create an issue in each project and an epic in each group
- Visit the epic in the root group and trigger the autocomplete by typing
#
in the description or a comment - Verify that the result includes the the epic in the root group and the issue in the root group's project