Search results page has poor performance
Summary
The performance of the search results page is not great. It doesn't seem to matter whether it's basic search or advanced search with Elasticsearch. Below are several different profiles, including one with basic search and advanced search.
It seems that most of the slowness in search is due to rendering, not actually retrieving data.
Steps to reproduce
With or without advanced search enabled, search for any term that will likely come back with a fair number of results. Run a Requests Profile on the search.
Profiles
These profiles are quite large and it's hard to do them justice in a screenshot. I've taken a small screenshot of each and also provided a Dropbox link to download the entire profile. I wonder if both cases can be improved at the same time, but if further investigation reveals that one or each require more work then we can split into two issues.
With advanced search enabled (from customer):
Here there seem to be multiple problems - of course the show
view is slow, just like with basic search. However, tons of 1-2% CI status lookups add considerable time, too.
https://www.dropbox.com/s/zfgh1mvfxe2enls/profile_for_1_16_2019.html?dl=0
Without advanced search enabled (from GitLab.com):
https://www.dropbox.com/s/j8s7g3lph45r78h/ruby-prof%20call%20tree1.htm?dl=0