diff options
author | Stan Hu <stanhu@gmail.com> | 2018-05-16 09:06:55 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-05-16 18:27:48 +0300 |
commit | e38938b332ca751dfc5e784f242d620016e8ca43 (patch) | |
tree | 439a6672547ba9d50d995e7717df28ab6ded89fd /app/helpers/count_helper.rb | |
parent | 0288e2525fbe2bc226726b5289fc6e5b3a949da2 (diff) |
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
Diffstat (limited to 'app/helpers/count_helper.rb')
-rw-r--r-- | app/helpers/count_helper.rb | 5 |
1 files changed, 5 insertions, 0 deletions
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 |