Skip to content

Instantly share code, notes, and snippets.

@RainJayTsai
Created December 7, 2018 02:56
Show Gist options
  • Save RainJayTsai/1ad279547b94d97a124cbb178435f488 to your computer and use it in GitHub Desktop.
Save RainJayTsai/1ad279547b94d97a124cbb178435f488 to your computer and use it in GitHub Desktop.
fast_read_big_mongo_collection_doc_counts
from pymongo import MongoClient
client = MongoClient('IP')
db = client['DB']
collection_name = 'your_full_collectaion_name'
resp = db.command('collstats',collection_name)
print(resp.get('count')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment