Remove Eager Load of last_deployment in EnvironmentFolder
What does this MR do?
Eager loading the
last_deployment here loads all the
deployments and all the
ci_builds for every
environment in the Environment Dashboard.
This can cause a
500 error with
ActiveRecord::QueryCanceled: PG::QueryCanceled: ERROR: canceling statement due to statement timeout with a project with enough data: https://log.gitlab.net/goto/f243231ba1b382b150b3eda3d8732ce7
I would imagine this is at least part of the culprit of the performance issues we've been discussing in !17645 (merged)
In contrast, if we don't preload these associations, we load one
Deployment and one
Ci::Build for each
Environment (2 queries, each of which use a
LIMIT 1 clause).
I would say we revert this to an N+1 to fix this issue. It may not solve all our problems, but I think it's a step in the right direction.
Does this MR meet the acceptance criteria?
- [-] Changelog entry
- [-] Documentation created/updated or follow-up review issue created
- Code review guidelines
- Merge request performance guidelines
- Style guides
- [-] Database guides
- [-] Separation of EE specific content
Performance and Testing
- [-] Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
- [-] Tested in all supported browsers
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team