Skip to content

Refactor and Optimize DashboardEnvironmentsSerializer/EnvironmentSerializer

Shinya Maeda requested to merge refactor-environment-dashboard-query into master

What does this MR do and why?

This MR addresses Remove using distinct sql clause for Environment associations preloading. Specifically, it changes the following things:

  • DashboardEnvironmentsSerializer batch-loads last_visible_* attributes through DeploymentPreloader. This is the recommended solution that was introduced for resolving performance issues of distinct_on_environment.
  • upcoming_deployment is used only in EnvironmentSerializer and already batch-loaded via DeploymentPreloader. This means the query doesn't need to rely on distinct_on_environment anymore.
  • Removing distinct_on_environment for preventing us from using it in the future. DeploymentPreloader should be used instead.

A few notes:

  • This MR does not change the business logic.

Related #349986 (closed)

Performance improvement by DeploymentPreloader

Previously

2022-07-28_14-28

(The profile was taken in https://gitlab.com/-/operations/environments)

Time: 11.268 s
  - planning: 5.337 ms
  - execution: 11.263 s
    - I/O read: 10.864 s
    - I/O write: 0.000 ms

New

Time: 20.533 ms
  - planning: 2.489 ms
  - execution: 18.044 ms
    - I/O read: 16.516 ms
    - I/O write: 0.000 ms

Screenshots or screen recordings

Environment Dashboard

2022-07-28_14-36

Environment Index Page

2022-07-28_14-42

How to set up and validate locally

Follow the documentation of Environment Dashboard or Environment Index Page.

MR acceptance checklist

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

Edited by Dylan Griffith

Merge request reports