Use linear version of groups_including_descendants_by
What does this MR do?
In this method we're switching the behavior of the Group#groups_including_descendants_by
method to use the linear version. The new behavior is behind the linear_group_including_descendants_by
feature flag.
How to setup and validate locally (strongly suggested)
- Enable the new method behavior feature flag
Feature.enable(:linear_group_including_descendants_by)
- In rails console enable the traversal id feature flag
Feature.enable(:use_traversal_ids)
SQL Queries
The former query before this change was:
WITH RECURSIVE base_and_descendants AS (
(SELECT namespaces.*
FROM namespaces
WHERE namespaces.type = 'Group'
AND namespaces.id IN (9970,
11932235))
UNION
(SELECT namespaces.*
FROM namespaces,
base_and_descendants
WHERE namespaces.type = 'Group'
AND namespaces.parent_id = base_and_descendants.id))
SELECT namespaces.*
FROM base_and_descendants AS namespaces
The new query is:
SELECT namespaces.*
FROM
(SELECT DISTINCT on(namespaces.id) namespaces.*
FROM namespaces,
(SELECT namespaces.id
FROM namespaces
WHERE namespaces.type = 'Group'
AND namespaces.id IN (9970,
11932235)) base
WHERE (namespaces.traversal_ids @> ARRAY[base.id])) namespaces
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Related to #339189 (closed)
Edited by Francisco Javier López