From e38938b332ca751dfc5e784f242d620016e8ca43 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 15 May 2018 23:06:55 -0700 Subject: Fix Error 500 viewing admin page due to statement timeouts Uses PostgreSQL tuple estimates to provide a much faster yet approximate count. See https://wiki.postgresql.org/wiki/Slow_Counting for more details. We only use this fast method if the table has been analyzed or vacuumed within the last hour. Closes #46255 --- app/views/admin/dashboard/index.html.haml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'app/views/admin/dashboard/index.html.haml') diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index bbf0e0fb95c..41ef646fc0e 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -10,7 +10,7 @@ = link_to admin_projects_path do %h3.text-center Projects: - = number_with_delimiter(Project.cached_count) + = approximate_count_with_delimiters(Project) %hr = link_to('New project', new_project_path, class: "btn btn-new") .col-sm-4 @@ -19,7 +19,7 @@ = link_to admin_users_path do %h3.text-center Users: - = number_with_delimiter(User.count) + = approximate_count_with_delimiters(User) %hr = link_to 'New user', new_admin_user_path, class: "btn btn-new" .col-sm-4 @@ -28,7 +28,7 @@ = link_to admin_groups_path do %h3.text-center Groups: - = number_with_delimiter(Group.count) + = approximate_count_with_delimiters(Group) %hr = link_to 'New group', new_admin_group_path, class: "btn btn-new" .row @@ -39,31 +39,31 @@ %p Forks %span.light.pull-right - = number_with_delimiter(ForkedProjectLink.count) + = approximate_count_with_delimiters(ForkedProjectLink) %p Issues %span.light.pull-right - = number_with_delimiter(Issue.count) + = approximate_count_with_delimiters(Issue) %p Merge Requests %span.light.pull-right - = number_with_delimiter(MergeRequest.count) + = approximate_count_with_delimiters(MergeRequest) %p Notes %span.light.pull-right - = number_with_delimiter(Note.count) + = approximate_count_with_delimiters(Note) %p Snippets %span.light.pull-right - = number_with_delimiter(Snippet.count) + = approximate_count_with_delimiters(Snippet) %p SSH Keys %span.light.pull-right - = number_with_delimiter(Key.count) + = approximate_count_with_delimiters(Key) %p Milestones %span.light.pull-right - = number_with_delimiter(Milestone.count) + = approximate_count_with_delimiters(Milestone) %p Active Users %span.light.pull-right -- cgit v1.2.1