summaryrefslogtreecommitdiff
path: root/doc/development/merge_request_performance_guidelines.md
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-26 03:16:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-26 03:16:17 +0000
commit037063e3004a6a86352adbc73d3034e9aaade32d (patch)
treed6a0e4d7136253aa032a56027defa5e311043092 /doc/development/merge_request_performance_guidelines.md
parent7a6bc43978731a70fe92d1d487e823a823b7f84e (diff)
downloadgitlab-ce-037063e3004a6a86352adbc73d3034e9aaade32d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/merge_request_performance_guidelines.md')
-rw-r--r--doc/development/merge_request_performance_guidelines.md8
1 files changed, 4 insertions, 4 deletions
diff --git a/doc/development/merge_request_performance_guidelines.md b/doc/development/merge_request_performance_guidelines.md
index 106db862122..c8e99e8547f 100644
--- a/doc/development/merge_request_performance_guidelines.md
+++ b/doc/development/merge_request_performance_guidelines.md
@@ -255,15 +255,15 @@ It re-instantiates project object for each build, instead of using the same in-m
In this particular case the workaround is fairly easy:
```ruby
+ActiveRecord::Associations::Preloader.new.preload(pipeline, [builds: :project])
+
pipeline.builds.each do |build|
- build.project = pipeline.project
build.to_json(only: [:name], include: [project: { only: [:name]}])
end
```
-We can assign `pipeline.project` to each `build.project`, since we know it should point to the same project.
-This allows us that each build point to the same in-memory project,
-avoiding the cached SQL query and re-instantiation of the project object for each build.
+`ActiveRecord::Associations::Preloader` uses the same in-memory object for the same project.
+This avoids the cached SQL query and also avoids re-instantiation of the project object for each build.
## Executing Queries in Loops