I am looking to get a random record from a huge (100 million record) mongodb.
mongodb
What is the fastest and most efficient way to do so? The data is already t
Using Python (pymongo), the aggregate function also works.
collection.aggregate([{'$sample': {'size': sample_size }}])
This approach is a lot faster than running a query for a random number (e.g. collection.find([random_int]). This is especially the case for large collections.