Reduce N+1 queries on deploy keys index page
What does this MR do?
This MR attempts to reduce the N+1 queries on deploy keys index page by preloading associations and memoizing some calculations.
The feature should be fundamentally changed in order to reduce the amount of data returned by the endpoint (pagination). This change is just stop gap solution.
Snippet for dev environment to generate some data, assuming that you use GDK with seeded DB:
project = Project.find_by_name("Gitlab Shell")
user = User.find_by_username("root")
other_project = Project.find_by_name("Gitlab Test")
10.times do
FactoryBot.create(:deploy_keys_project, project: project, deploy_key: FactoryBot.create(:deploy_key, user: user))
end
10.times do
FactoryBot.create(:deploy_keys_project, project: other_project, deploy_key: FactoryBot.create(:deploy_key, user: user))
end
10.times do
FactoryBot.create(:deploy_key, public: true)
end
Check deploy keys for Gitlab Shell
project.
Related issue: #21059 (closed)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
Edited by Mayra Cabrera