Fix counting of groups in admin dashboard
This merge request does two things:
-
Ignore tables that use STI in reltuples count strategy.
Models that use Rails' single-type inheritance, such as
Group
andCiService
, need an additional WHERE clause to count the total properly, which isn't supported by the reltuples strategy. For now, we just omit these from the statistics sampling and rely on the other strategies to get this data. -
Makes the tablesample count strategy work properly with STI models.
Models such as
Group
needs a WHERE clause to distinguish it from namespaces. We now add in the WHERE clause if STI is in use.
Even the exact count for Group
isn't that expensive on GitLab.com:
[ gprd ] production> Group.count
D, [2019-03-12T06:52:05.142944 #12496] DEBUG -- : (396.5ms) SELECT COUNT(*) FROM "namespaces" WHERE "namespaces"."type" IN ('Group')
=> 811129
Edited by Stan Hu