Apply `without_count: true` to the `group/{id}/audit_events` API endpoint
Description
In the issue API endpoint to retrieve all audit events under a given group, we added a query to return all of the project audit events under a group in addition to the group-level audit events.
The query appears to work ok, however the COUNT
that happens before the query ends up timing out. The problem is the count query attempts to count 10001 rows. That reads 100x more data than the pagination query where we return only 100 rows.
https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/19249/commands/63576
Proposed Solution
For large datasets, of which the audit_events
table qualifies, we usually skip the default behavior of doing a count query
The paginate()
method accepts a without_count: true|false
flag. We should add a toggle of that flag with a FF.
We want to be able to make sure that whenever audit_event_group_rollup
FF is enabled, this is enabled. However we also want to be able to toggle the paginate flag independently
something like the following should do the trick:
# if audit_event_group_rollup is enabled we *must* paginate without a count.
# If audit_event_group_rollup is disabled we can experiment with toggling count on and off
without_count = Feature.enabled?(:audit_event_group_rollup, group) ||
Feature.enabled?(:disable_pagination_counts_on_group_audit_events, group)