Skip to content

Fix N+1 problem in the pipeline bridges API endpoint

Furkan Ayhan requested to merge 435069-nplusone-pipeline-bridges-api into master

What does this MR do and why?

The "GET /api/:version/projects/:id/pipelines/:pipeline_id/bridges" endpoint renders the user relation of the bridges. Besides, followers and following are rendered for each user, so all of these raise N+1 SQL query problems.

In this change, we are adding "user: [:followers, :followees]" to preload these.

Related to #435069 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Current duration, DB count, and DB duration of this endpoint; https://log.gprd.gitlab.net/app/r/s/lCCkV

Screenshot_2024-05-28_at_10.39.32

I expect that this will get lower.

Edited by Furkan Ayhan

Merge request reports

Loading