Once #6055 is fixed, we can replace the previous in-memory optimization with a proper in-database optimization that actually works across threads.
My current thinking is to just use the meta store and roughly use the same code as before but attaching the docCount to the database instead of in-memory
(#6068) - safely re-implement IDB docCount optimization
(#6068) - safely reimplement IDB docCount optimization
Fixed in 4a1b4e4