Skip to content

Restore optimized MR metrics queries

Adam Hegyi requested to merge 391787-restore-the-optimized-mr-metrics-query into master

What does this MR do and why?

This MR restores the optimizes MR metrics-based queries which are used on the merge request analytics page: https://gitlab.com/gitlab-org/gitlab/-/analytics/merge_request_analytics

The problem was the extra not (mostly empty) filters which were not taken into account when determining whether to use the optimization or not.

How to set up and validate locally

  1. Go to Project > Analytics > Merge Request
  2. See the application logs and find DB queries only querying the merge_request_metrics table.
SELECT COUNT(*)
FROM "merge_request_metrics"
WHERE "merge_request_metrics"."target_project_id" = 1
  AND "merge_request_metrics"."merged_at" >= '2022-02-20 23:00:00'
  AND "merge_request_metrics"."merged_at" <= '2022-02-28 23:00:00'

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #391787 (closed)

Edited by Adam Hegyi

Merge request reports