How do I change DB Query shellBatchSize in MongoDB

By default MongoDB displays 20 records in the results for any DB query (which results more than 20 records ) & you can see the next set of result by pressing ‘it’ (iteration) in the prompt.

However, you can change the default DB query shell batch size using the below option and display any number of records you want.

[root@dbversity.com bin]# ./mongo
MongoDB shell version: 3.0.1
connecting to: test
>
>

> DBQuery.shellBatchSize = 40

40
> // To create bulk inserts in the mongodb using a JS for loop
> for(var i = 1; i <= 1000 ; i++){db.test_collection.insert({“_id” : i , “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : i }); sleep(1);}
null
>
> db.test_collection.find()
{ “_id” : 1, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 1 }
{ “_id” : 2, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 2 }
{ “_id” : 3, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 3 }
{ “_id” : 4, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 4 }
{ “_id” : 5, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 5 }
{ “_id” : 6, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 6 }
{ “_id” : 7, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 7 }
{ “_id” : 8, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 8 }
{ “_id” : 9, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9 }
{ “_id” : 10, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 10 }
{ “_id” : 11, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 11 }
{ “_id” : 12, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 12 }
{ “_id” : 13, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 13 }
{ “_id” : 14, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 14 }
{ “_id” : 15, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 15 }
{ “_id” : 16, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 16 }
{ “_id” : 17, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 17 }
{ “_id” : 18, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 18 }
{ “_id” : 19, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 19 }
{ “_id” : 20, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 20 }
{ “_id” : 21, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 21 }
{ “_id” : 22, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 22 }
{ “_id” : 23, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 23 }
{ “_id” : 24, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 24 }
{ “_id” : 25, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 25 }
{ “_id” : 26, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 26 }
{ “_id” : 27, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 27 }
{ “_id” : 28, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 28 }
{ “_id” : 29, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 29 }
{ “_id” : 30, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 30 }
{ “_id” : 31, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 31 }
{ “_id” : 32, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 32 }
{ “_id” : 33, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 33 }
{ “_id” : 34, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 34 }
{ “_id” : 35, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 35 }
{ “_id” : 36, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 36 }
{ “_id” : 37, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 37 }
{ “_id” : 38, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 38 }
{ “_id” : 39, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 39 }
{ “_id” : 40, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 40 }
Type “it” for more
>

  • Ask Question