diff options
author | Stan Hu <stanhu@gmail.com> | 2019-09-10 03:05:55 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-09-10 07:51:57 +0300 |
commit | 08c3e59aeed34ad71e74afb674ddda7327fdc3a7 (patch) | |
tree | 544d9fa244519ac8b18b29ff8abf47bfdd40b30a /app/views/admin/applications | |
parent | ffa5328c39f195d3253e586569fc2474d3aa6860 (diff) |
Optimize /admin/applications so that it does not timeout
On our dev instance, /admin/applications as not loading because:
1. There was an unindexed query by `application_id`.
2. There was an expensive query that attempted to load 1 million
unique entries via ActiveRecord just to find the unique count.
We fix the first issue by adding an index for that column.
We fix the second issue with a simple SELECT COUNT(DISTINCT
resource_owner_id) SQL query.
In addition, we add pagination to avoid loading more than 20
applications at once.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/67228
Diffstat (limited to 'app/views/admin/applications')
-rw-r--r-- | app/views/admin/applications/index.html.haml | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/app/views/admin/applications/index.html.haml b/app/views/admin/applications/index.html.haml index 2cdf98075d1..758d722cc63 100644 --- a/app/views/admin/applications/index.html.haml +++ b/app/views/admin/applications/index.html.haml @@ -19,7 +19,8 @@ %tr{ :id => "application_#{application.id}" } %td= link_to application.name, admin_application_path(application) %td= application.redirect_uri - %td= application.access_tokens.map(&:resource_owner_id).uniq.count + %td= @application_counts[application.id].to_i %td= application.trusted? ? 'Y': 'N' %td= link_to 'Edit', edit_admin_application_path(application), class: 'btn btn-link' %td= render 'delete_form', application: application += paginate @applications, theme: 'gitlab' |