-
- Downloads
Fix pseudo n+1 queries with Note and Note Authors in issuables APIs
This was not a clear cut n+1 query, given that if you're directly subscribed to all issues that the API is returning you never really need to check for the notes. However, if you're subscribed to _all_ of them, then for each issuable you need to go once to `notes`, and once to `users` (for the authors). By preemtively loading notes and authors, at worst you have 1 extra query, and at best you saved 2n extra queries. We also took advantage of this preloading of notes when counting user notes.
Showing
- app/models/concerns/issuable.rb 21 additions, 3 deletionsapp/models/concerns/issuable.rb
- lib/api/issues.rb 2 additions, 2 deletionslib/api/issues.rb
- lib/api/merge_requests.rb 1 addition, 1 deletionlib/api/merge_requests.rb
- spec/models/concerns/issuable_spec.rb 26 additions, 0 deletionsspec/models/concerns/issuable_spec.rb
Please register or sign in to comment