Since MongoDB 3.2, it can be done using aggregate function with $sample operator, as described in docs. It's super fast. Following code will randomly select 20 documents from collection. db.collection.aggregate( [ {$sample: {size: 20} } ] )
if you need to select random documents with specific criteria, you can use it with $match opperator db.collection.aggregate([ {$sample: {size: 20} },