ReindexAllIssues has N+1 query
Summary
There is an N+1 in the ReindexAllIssues
advanced search migration. The N+1 is due to calling maintain_elasticsearch?
on each record which calls use_elasticsearch?
which loads the project record.
Note: this only affects instances which use elasticsearch limiting feature in Advanced search
Relevant logs and/or screenshots
The screenshot shows the issue, the migration should process 50_000
records at a time but are seeing > 50_000
database calls
Possible fixes
- add a preload of the project record in the migration helper
- this preload could be a mandatory method that the migration must define which preloads data if needed
- add a spec using the query recorder
Edited by Terri Chu