Fix Service ping failing metrics for ecosystem stage (3)
What does this MR do and why?
The following metrics are failing in GitLab.com for devopsecosystem due to performance problem, that makes query time out on database. Comment here
counts.groups_inheriting_gitlab_slack_application_active
counts.groups_campfire_active
counts.groups_github_active
counts.groups_inheriting_github_active
counts.groups_flowdock_active
Screenshots or screen recordings
LINK
Without indexes:LINK
With new indexes:How to set up and validate locally
- Go to https://console.postgres.ai/gitlab/joe-instances/34 to check the performance
- Run the following query:
explain SELECT MIN("integrations"."id") FROM "integrations" WHERE "integrations"."active" = TRUE AND "integrations"."group_id" IS NOT NULL AND "integrations"."inherit_from_id" IS NOT NULL AND "integrations"."type_new" = 'Integrations::GitlabSlackApplication'
- Execute the
reset
command to revert the database to the initial state - Execute the following commands:
exec CREATE INDEX index_integrations_on_type_new_id_when_active_and_has_group ON integrations USING btree (type_new, id) WHERE ((active = true) AND (group_id IS NOT NULL));
- Run again the query from the step 2.
- Compare the results
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #366401 (closed)
Edited by Bojan Marjanovic