Improve performance of querying alert assignees - attempt 2
What does this MR do?
!33656 (merged) was reverted due to some unexpected conflicts (namely removal of support for FilterableArray
in graphql connections). This MR reimplements that fix, with a slight adjustment to approach.
Context
Querying AlertManagementAlerts with the assignee field through the GraphQL API would result in a N+1 query.
This fixes the query by using LooksAhead
to preload the assignee association before querying the DB.
This is currently behind a feature flag (:alert_assignee
) which simply returns an empty collection if not enabled. I'm leaving the flag in place for now. This also requires the :graphql_lookahead_support
feature flag to be enabled to see the performance improvement.
Related issue: #219571 (closed)
Blocks: #219571 (closed)
Screenshots
Graphql verification | logs output |
---|---|
UI verification | logs output |
---|---|
Out of scope: this solution only handles a single connection, as that is the important use case for our scenario. If this becomes a scenario we want to handle down the road, we can do that later.
So a query like this one would have a separate query for each alert:
{
project(fullPath: "root/autodevops") {
id
fullPath
alert5: alertManagementAlert(iid: "5") {
iid
status
assignees {
nodes {
username
}
}
}
alert2: alertManagementAlert(iid: "2") {
iid
status
assignees {
nodes {
username
}
}
}
}
}
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry - feature flag
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team