`Projects::MergeRequests::ContentController#widget` triggers too many DB queries
Description
Projects::MergeRequests::ContentController#widget
is one of the top endpoints that triggers a massive amount of database queries:
- Order by
sum(db_count)
:
- Order by
sum(db_primary_count)
The investigation is still going on. I'll constantly update the progress in this issue.
Impact
The spike of DB queries is no longer observed, and the peak queries dropped from 2M to ~0.5M, a 4x improvement. See details in #326277 (comment 547679868).