Home > database >  Is there a quick way to get the total count for mongodb paging?
Is there a quick way to get the total count for mongodb paging?

Time:03-08

A total count is required for mongodb paging. Is there a quick way to get it without using the PagingModel.count() method?

The amount of data is over 1 million.

CodePudding user response:

collection.count() is the quickest since it reads the collection metadata info ...

CodePudding user response:

You can have a different collection in which you store the statistics for the collection and you keep it updated (e.g. you add a document to the "tracking" collection, you also add 1 to the count in the "statistics" collection).

  • Related