Count relation sizes async to web requests
Currently, we estimate the size of a relation by looking at postgres statistics. Those can be quite off: https://gitlab.com/gitlab-org/gitlab-ce/issues/48348#note_87981984
We can solve this with counting relation sizes in background and storing the count in Redis. On insert or deletion, we'd increment the counter. If the count is not available, we'll disable a "? still counting ?" in the frontend (you know, similar to that). The cached count lives in Redis for a while and can be timed out/flushed to refresh from an actual count.
Details from https://gitlab.com/gitlab-org/gitlab-ce/issues/48348#note_87981984:
If we wanted to cache the count, we could store it in Redis and increment/decrement on insert/delete. To get the initial count (ie on a cache miss), we could fire up a background worker to count the relation in batches of the primary key (first N rows by id, second N rows by id and so on). This means, we'd have to display a "?" in case we don't know the actual count yet. Also, it may show a slightly wrong count if records are deleted during the count phase (in a batch we've already looked at previously in the process). Inserts come with a similar problem, although the impact is probably not as great as with deletes considering the primary key order.