Refactor and Optimize DashboardEnvironmentsSerializer/EnvironmentSerializer
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:
-
DashboardEnvironmentsSerializerbatch-loadslast_visible_*attributes throughDeploymentPreloader. This is the recommended solution that was introduced for resolving performance issues ofdistinct_on_environment. -
upcoming_deploymentis used only inEnvironmentSerializerand already batch-loaded viaDeploymentPreloader. This means the query doesn't need to rely ondistinct_on_environmentanymore. - Removing
distinct_on_environmentfor preventing us from using it in the future.DeploymentPreloadershould be used instead.
A few notes:
- This MR does not change the business logic.
Related #349986 (closed)
Performance improvement by DeploymentPreloader
Previously
(The profile was taken in https://gitlab.com/-/operations/environments)
- Query and Plan: https://gitlab.slack.com/archives/CLJMDRD8C/p1658986208341249 https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/11225/commands/40075
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
- Query and Plan: https://gitlab.slack.com/archives/CLJMDRD8C/p1658986225585949 https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/11225/commands/40076
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
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.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Dylan Griffith


