The query implemented in this diff is fast on our dataset (P569).
But, that currently fails on db storage tests.
Because it relies on the `object_counts` table and it seems to fail to update in test context.
What would be a better way to implement or test this?
Note:
Related to T2120