Slow performance on "Explore Snippets"

Summary

Loading https://gitlab.com/explore/snippets is very slow, taking around ~20s per page.

Improvements

At first glance I noticed:

  • Fix N+1 queries for snippet users and comments

Not sure if that alone will fix it, we might want to check for other problems.

Involved components

  • Explore::SnippetsController
  • SnippetsFinder
  • related views in app/views/explore/snippets and app/views/shared/snippets