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/helpers/count_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/helpers/count_helper.rb (limited to 'app/helpers/count_helper.rb') diff --git a/app/helpers/count_helper.rb b/app/helpers/count_helper.rb new file mode 100644 index 00000000000..24ee62e68ba --- /dev/null +++ b/app/helpers/count_helper.rb @@ -0,0 +1,5 @@ +module CountHelper + def approximate_count_with_delimiters(model) + number_with_delimiter(Gitlab::Database::Count.approximate_count(model)) + end +end -- cgit v1.2.1