Seed tablesample strategy

This produces stable approximate counts among invocations unless the
table changed.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/58791.
This commit is contained in:
Andreas Brandl 2019-03-11 14:50:13 +01:00
parent 27644f63fb
commit ded299c05b
No known key found for this signature in database
GPG key ID: F25982B13FEE55DA

View file

@ -61,6 +61,7 @@ module Gitlab
SELECT (COUNT(*)*#{inverse})::integer AS count
FROM #{model.table_name}
TABLESAMPLE SYSTEM (#{portion * 100})
REPEATABLE (0)
#{where_clause(model)}
SQL