LibreCat / Catmandu-Store-MongoDB

A searchable store backed by MongoDB
https://metacpan.org/pod/Catmandu::Store::MongoDB
4 stars 2 forks source link

Add a feature to use an estimated_document_count when searching or counting with a query #17

Closed phochste closed 3 years ago

phochste commented 3 years ago

This Catmandu package uses the count_document method on Mongo collections to calculate the collection size. This is a very fast operation when no query is provided but a very slow operation on very big MongoDB collections with a query.

Provide an optimization flag e.g. estimate_count => 1 that results in using estimated_document_count when a query is provided and count_document when no query is provided.

nics commented 3 years ago

estimated_document_count doesn't take a filter argument, it can only give a guesstimate of the whole collection

phochste commented 3 years ago

@nics My mistake..I meant the other way around it is very slow to know the size of a Mongo database and this can be optimized with an estimated_document_count

nics commented 3 years ago

added estimate_count option to store in 0.0804, can you help test it's effect?