Comments search has a high number of database calls

Summary

There is a high number of calls to the database when loading comments search results.

Steps to reproduce

  1. enable the performance bar
  2. perform a global comments search: https://gitlab.com/search?scope=notes&search=test
  3. for the search I performed, there were 217 postgres calls

image

What is the current bug behavior?

There are some (undetected) N+1 calls for comments search results

Possible fixes