Add a flag to use a subquery for group issues search
What does this MR do?
For full history, see the follow-up issue https://gitlab.com/gitlab-org/gitlab-ce/issues/54643.
We already had a flag to use a CTE, but this broke searching in some cases where we need to sort by a joined table. Disabling the CTE flag makes searches much slower.
The new flag, to use a subquery, makes them slightly slower than the CTE, while maintaining correctness. If both it and the CTE flag are enabled, the subquery takes precedence.
Test results: https://gitlab.com/gitlab-org/gitlab-ce/snippets/1785488
Note that the group issues query is slightly slower after: this is hopefully acceptable given the above.
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides -
Security reports checked/validated by reviewer