{"id":55840,"date":"2018-03-02T11:00:58","date_gmt":"2018-03-02T09:00:58","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=55840"},"modified":"2018-03-02T10:35:53","modified_gmt":"2018-03-02T08:35:53","slug":"mongodb-batchsize-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/","title":{"rendered":"MongoDB batchSize() Example"},"content":{"rendered":"<p>Hello readers, these days to increase the system performance it is important to retrieve the records from a database in <em>batches<\/em>. In Mongo world, it is pretty straightforward and in this tutorial, we will see the <code>cursor.batchSize()<\/code> method available in the Mongo database. Let&#8217;s study in brief the usage of this method.<\/p>\n<h2>1. Introduction<\/h2>\n<p>If you have installed the MongoDB application (<em>version 3.6<\/em>) on Windows or Ubuntu operating system and you wish to learn the <code>cursor.batchSize()<\/code> method then follow the below steps. It is very simple, but before moving further let&#8217;s take a look at the Mongo database and its features.<\/p>\n<h3>1.1 What is MongoDB?<\/h3>\n<ul>\n<li>MongoDB is a high-performance <em>NoSQL database<\/em> where each database has collections which in turn has documents. Each document has a different number of fields, size, content, and is stored in a JSON-like format (i.e. Binary JSON (<a href=\"https:\/\/en.wikipedia.org\/wiki\/BSON\" target=\"_blank\" rel=\"noopener\">BSN<\/a>)<\/li>\n<li>The documents in MongoDB doesn\u2019t need to have a schema defined beforehand. Instead, the fields (i.e. <em>records<\/em>) can be created on the go<\/li>\n<li>Data model available within the MongoDB allows developers to represent the hierarchical relationships, store arrays, and other more complex structures easily<\/li>\n<li>This NoSQL solution often comes with embedding, auto-sharding, and onboard replication for better scalability and high availability<\/li>\n<\/ul>\n<h4>1.1.1 Why MongoDB?<\/h4>\n<ul>\n<li>As a NoSQL type database, MongoDB stores the data in the form of a document. Thus, MongoDB offers more flexibility<\/li>\n<li>This database supports search by field-name, range queries, and the regular expressions. It often provides queries to return the particular fields inside the documents<\/li>\n<li>MongoDB offers <em>indexes<\/em> to improve the <em>search performance<\/em> within the NoSQL database<\/li>\n<li>To offer horizontal scalability, MongoDB uses sharding by splitting the data across the many MongoDB occurrences<\/li>\n<li><strong>Replication<\/strong>: MongoDB can give high availability with the replica sets<\/li>\n<\/ul>\n<h3>1.2 What is a Cursor in MongoDB?<\/h3>\n<p>In Mongo world, a <strong>cursor<\/strong> is an object that allows developers to iterate through the documents of a Mongo collection. The behavior of cursor allows an automatic iteration across the results of the query; however, developers can explicitly go through the items returned in the cursor object. The below diagram lists <code>4<\/code> documents where the Mongo <em>cursor<\/em> will point to the first document and then iterate through all the other documents of a collection.<\/p>\n<p><figure id=\"attachment_55841\" aria-describedby=\"caption-attachment-55841\" style=\"width: 673px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-archi-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55841\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-archi-guide-1.jpg\" alt=\"Fig. 1: Pictorial representation of a Cursor in Mongo collection\" width=\"673\" height=\"492\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-archi-guide-1.jpg 673w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-archi-guide-1-300x219.jpg 300w\" sizes=\"(max-width: 673px) 100vw, 673px\" \/><\/a><figcaption id=\"caption-attachment-55841\" class=\"wp-caption-text\">Fig. 1: Pictorial representation of a Cursor in Mongo collection<\/figcaption><\/figure><\/p>\n<h4>1.2.1 Why Cursor in MongoDB?<\/h4>\n<p>Cursor offers:<\/p>\n<ul>\n<li>A true snapshot of a system i.e. it returns the data in batches and increases the database performance<\/li>\n<li>It saves system memory by allowing batch inserts and updates<\/li>\n<li>Intelligibility and Clarity on the ad-hoc and complex queries of the sequential nature having large result sets and low consistency requirements<\/li>\n<li>Openness to work on small batches of data as developers don\u2019t need to wait for the processing and download of the complete record-set<\/li>\n<\/ul>\n<h2>2. MongoDB batchSize() Example<\/h2>\n<p>In this Mongo tutorial, we will learn how to handle the <code>cursor.batchSize()<\/code> method provided by the Mongo database.<\/p>\n<h3>2.1 batchSize() method in the Mongo database<\/h3>\n<p>In the Mongo universe, the <code><a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/method\/cursor.batchSize\/#cursor.batchSize\" target=\"_blank\" rel=\"noopener\">batchSize()<\/a><\/code> method specifies the number of documents that the Mongo instance will return to the user in a single network message. In simpler words, this method controls the number of documents to be returned in each response batch from the Mongo instance. However, it will never return more documents that fit in the max batch size limit (usually 4 MB) and this is what the query syntax will look like.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Mongo database batchSize() Syntax<\/em><\/span><\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.collection_name.find().batchSize(&lt;size_parameter&gt;)\r\n<\/pre>\n<p>Where:<\/p>\n<ul>\n<li><strong>size_parameter<\/strong> is an optional integer type input variable that specifies the number of documents to be returned per batch<\/li>\n<\/ul>\n<p>Do <strong>remember<\/strong>:<\/p>\n<ul>\n<li>Using a batch of size <code>1<\/code> as specifying <code>1<\/code> or a negative number is like using the Mongo database <code><a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/method\/cursor.limit\/#cursor.limit\" target=\"_blank\" rel=\"noopener\">limit()<\/a><\/code> method<\/li>\n<li>Using a batch of size <code>2<\/code> or more, represents the retrieval size of each batch of objects. This can be adjusted to optimize performance and limit the data transfer<\/li>\n<\/ul>\n<p>Let&#8217;s understand this with the help of an example.<\/p>\n<h4>2.1.1 Start MongoDB<\/h4>\n<p>Start a standalone <a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/program\/mongod\/#bin.mongod\" target=\"_blank\" rel=\"noopener\">mongod<\/a> instance as shown below.<\/p>\n<p><figure id=\"attachment_55842\" aria-describedby=\"caption-attachment-55842\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55842\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-1.jpg\" alt=\"Fig. 2: Start Mongo instance\" width=\"849\" height=\"613\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-1.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-1-300x217.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-1-768x555.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-55842\" class=\"wp-caption-text\">Fig. 2: Start Mongo instance<\/figcaption><\/figure><\/p>\n<h4>2.1.2 Connect to the Mongo Instance<\/h4>\n<p>Connect with the <a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/program\/mongo\/#bin.mongo\" target=\"_blank\" rel=\"noopener\">mongo<\/a> shell to make a connection with the MongoDB instance on the port <code>27017<\/code> as shown below.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><figure id=\"attachment_55843\" aria-describedby=\"caption-attachment-55843\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55843\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-2.jpg\" alt=\"Fig. 3: Connect to Mongo database\" width=\"849\" height=\"362\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-2.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-2-300x128.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-2-768x327.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-55843\" class=\"wp-caption-text\">Fig. 3: Connect to Mongo database<\/figcaption><\/figure><\/p>\n<h4>2.1.3 Create Mongo database and collection<\/h4>\n<p>To begin with the implementation, we will need to create a sample database and collection. The below script creates a database called <code>editors<\/code> with a collection of <code>exam_scores<\/code>. Open the Mongo terminal and execute the script.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Database &amp; Collection creation script<\/em><\/span><\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; use editors\r\n\r\n&gt; db.exam_scores.insertMany( [\r\n\t{\"_id\":0,\"name\":\"aimee Zank\",\"scores\":[{\"score\":1.463179736705023,\"type\":\"exam\"},{\"score\":11.78273309957772,\"type\":\"quiz\"},{\"score\":35.8740349954354,\"type\":\"homework\"}]},\r\n\t{\"_id\":1,\"name\":\"Aurelia Menendez\",\"scores\":[{\"score\":60.06045071030959,\"type\":\"exam\"},{\"score\":52.79790691903873,\"type\":\"quiz\"},{\"score\":71.76133439165544,\"type\":\"homework\"}]},\r\n\t{\"_id\":2,\"name\":\"Corliss Zuk\",\"scores\":[{\"score\":67.03077096065002,\"type\":\"exam\"},{\"score\":6.301851677835235,\"type\":\"quiz\"},{\"score\":66.28344683278382,\"type\":\"homework\"}]},\r\n\t{\"_id\":3,\"name\":\"Bao Ziglar\",\"scores\":[{\"score\":71.64343899778332,\"type\":\"exam\"},{\"score\":24.80221293650313,\"type\":\"quiz\"},{\"score\":42.26147058804812,\"type\":\"homework\"}]},\r\n\t{\"_id\":4,\"name\":\"Zachary Langlais\",\"scores\":[{\"score\":78.68385091304332,\"type\":\"exam\"},{\"score\":90.2963101368042,\"type\":\"quiz\"},{\"score\":34.41620148042529,\"type\":\"homework\"}]},\r\n\t{\"_id\":5,\"name\":\"Wilburn Spiess\",\"scores\":[{\"score\":44.87186330181261,\"type\":\"exam\"},{\"score\":25.72395114668016,\"type\":\"quiz\"},{\"score\":63.42288310628662,\"type\":\"homework\"}]},\r\n\t{\"_id\":6,\"name\":\"Jenette Flanders\",\"scores\":[{\"score\":37.32285459166097,\"type\":\"exam\"},{\"score\":28.32634976913737,\"type\":\"quiz\"},{\"score\":81.57115318686338,\"type\":\"homework\"}]},\r\n\t{\"_id\":7,\"name\":\"Salena Olmos\",\"scores\":[{\"score\":90.37826509157176,\"type\":\"exam\"},{\"score\":42.48780666956811,\"type\":\"quiz\"},{\"score\":96.52986171633331,\"type\":\"homework\"}]},\r\n\t{\"_id\":8,\"name\":\"Daphne Zheng\",\"scores\":[{\"score\":22.13583712862635,\"type\":\"exam\"},{\"score\":14.63969941335069,\"type\":\"quiz\"},{\"score\":75.94123677556644,\"type\":\"homework\"}]},\r\n\t{\"_id\":9,\"name\":\"Sanda Ryba\",\"scores\":[{\"score\":97.00509953654694,\"type\":\"exam\"},{\"score\":97.80449632538915,\"type\":\"quiz\"},{\"score\":25.27368532432955,\"type\":\"homework\"}]},\r\n\t{\"_id\":10,\"name\":\"Denisha Cast\",\"scores\":[{\"score\":45.61876862259409,\"type\":\"exam\"},{\"score\":98.35723209418343,\"type\":\"quiz\"},{\"score\":55.90835657173456,\"type\":\"homework\"}]},\r\n\t{\"_id\":11,\"name\":\"Marcus Blohm\",\"scores\":[{\"score\":78.42617835651868,\"type\":\"exam\"},{\"score\":82.58372817930675,\"type\":\"quiz\"},{\"score\":87.49924733328717,\"type\":\"homework\"}]},\r\n\t{\"_id\":12,\"name\":\"Quincy Danaher\",\"scores\":[{\"score\":54.29841278520669,\"type\":\"exam\"},{\"score\":85.61270164694737,\"type\":\"quiz\"},{\"score\":80.40732356118075,\"type\":\"homework\"}]},\r\n\t{\"_id\":13,\"name\":\"Jessika Dagenais\",\"scores\":[{\"score\":90.47179954427436,\"type\":\"exam\"},{\"score\":90.3001402468489,\"type\":\"quiz\"},{\"score\":95.17753772405909,\"type\":\"homework\"}]},\r\n\t{\"_id\":14,\"name\":\"Alix Sherrill\",\"scores\":[{\"score\":25.15924151998215,\"type\":\"exam\"},{\"score\":68.64484047692098,\"type\":\"quiz\"},{\"score\":24.68462152686763,\"type\":\"homework\"}]},\r\n\t{\"_id\":15,\"name\":\"Tambra Mercure\",\"scores\":[{\"score\":69.1565022533158,\"type\":\"exam\"},{\"score\":3.311794422000724,\"type\":\"quiz\"},{\"score\":45.03178973642521,\"type\":\"homework\"}]},\r\n\t{\"_id\":16,\"name\":\"Dodie Staller\",\"scores\":[{\"score\":7.772386442858281,\"type\":\"exam\"},{\"score\":31.84300235104542,\"type\":\"quiz\"},{\"score\":80.52136407989194,\"type\":\"homework\"}]},\r\n\t{\"_id\":17,\"name\":\"Fletcher Mcconnell\",\"scores\":[{\"score\":39.41011069729274,\"type\":\"exam\"},{\"score\":81.13270307809924,\"type\":\"quiz\"},{\"score\":97.70116640402922,\"type\":\"homework\"}]},\r\n\t{\"_id\":18,\"name\":\"Verdell Sowinski\",\"scores\":[{\"score\":62.12870233109035,\"type\":\"exam\"},{\"score\":84.74586220889356,\"type\":\"quiz\"},{\"score\":81.58947824932574,\"type\":\"homework\"}]},\r\n\t{\"_id\":19,\"name\":\"Gisela Levin\",\"scores\":[{\"score\":44.51211101958831,\"type\":\"exam\"},{\"score\":0.6578497966368002,\"type\":\"quiz\"},{\"score\":93.36341655949683,\"type\":\"homework\"}]},\r\n\t{\"_id\":20,\"name\":\"Tressa Schwing\",\"scores\":[{\"score\":42.17439799514388,\"type\":\"exam\"},{\"score\":71.99314840599558,\"type\":\"quiz\"},{\"score\":81.23972632069464,\"type\":\"homework\"}]},\r\n\t{\"_id\":21,\"name\":\"Rosana Vales\",\"scores\":[{\"score\":46.2289476258328,\"type\":\"exam\"},{\"score\":98.34164225207036,\"type\":\"quiz\"},{\"score\":36.18769746805938,\"type\":\"homework\"}]},\r\n\t{\"_id\":22,\"name\":\"Margart Vitello\",\"scores\":[{\"score\":75.04996547553947,\"type\":\"exam\"},{\"score\":10.23046475899236,\"type\":\"quiz\"},{\"score\":96.72520512117761,\"type\":\"homework\"}]},\r\n\t{\"_id\":23,\"name\":\"Tamika Schildgen\",\"scores\":[{\"score\":45.65432764125526,\"type\":\"exam\"},{\"score\":64.32927049658846,\"type\":\"quiz\"},{\"score\":83.53933351660562,\"type\":\"homework\"}]},\r\n\t{\"_id\":24,\"name\":\"Jesusa Rickenbacker\",\"scores\":[{\"score\":86.0319702155683,\"type\":\"exam\"},{\"score\":1.967495200433389,\"type\":\"quiz\"},{\"score\":61.10861071547914,\"type\":\"homework\"}]},\r\n\t{\"_id\":25,\"name\":\"Rudolph Domingo\",\"scores\":[{\"score\":74.75289335591543,\"type\":\"exam\"},{\"score\":38.5413647805495,\"type\":\"quiz\"},{\"score\":35.2554340953413,\"type\":\"homework\"}]},\r\n\t{\"_id\":26,\"name\":\"Jonie Raby\",\"scores\":[{\"score\":19.17861192576963,\"type\":\"exam\"},{\"score\":76.3890359749654,\"type\":\"quiz\"},{\"score\":44.39605672647002,\"type\":\"homework\"}]},\r\n\t{\"_id\":27,\"name\":\"Edgar Sarkis\",\"scores\":[{\"score\":8.606983261043888,\"type\":\"exam\"},{\"score\":58.71180464203724,\"type\":\"quiz\"},{\"score\":15.33726210596508,\"type\":\"homework\"}]},\r\n\t{\"_id\":28,\"name\":\"Laureen Salomone\",\"scores\":[{\"score\":3.677565278992456,\"type\":\"exam\"},{\"score\":7.119462599229987,\"type\":\"quiz\"},{\"score\":82.87308922617427,\"type\":\"homework\"}]},\r\n\t{\"_id\":29,\"name\":\"Gwyneth Garling\",\"scores\":[{\"score\":48.36644963899371,\"type\":\"exam\"},{\"score\":10.37827022865908,\"type\":\"quiz\"},{\"score\":93.26639335532833,\"type\":\"homework\"}]},\r\n\t{\"_id\":30,\"name\":\"Kaila Deibler\",\"scores\":[{\"score\":15.89771199662455,\"type\":\"exam\"},{\"score\":56.93965183412178,\"type\":\"quiz\"},{\"score\":66.64493295066322,\"type\":\"homework\"}]},\r\n\t{\"_id\":31,\"name\":\"Tandra Meadows\",\"scores\":[{\"score\":24.90138146001744,\"type\":\"exam\"},{\"score\":28.8266541837344,\"type\":\"quiz\"},{\"score\":97.16831550665721,\"type\":\"homework\"}]},\r\n\t{\"_id\":32,\"name\":\"Gwen Honig\",\"scores\":[{\"score\":87.14345376886205,\"type\":\"exam\"},{\"score\":99.45824441135635,\"type\":\"quiz\"},{\"score\":76.66460454219344,\"type\":\"homework\"}]},\r\n\t{\"_id\":33,\"name\":\"Sadie Jernigan\",\"scores\":[{\"score\":73.15861249943812,\"type\":\"exam\"},{\"score\":2.987718065941702,\"type\":\"quiz\"},{\"score\":82.54104198590488,\"type\":\"homework\"}]},\r\n\t{\"_id\":34,\"name\":\"Carli Belvins\",\"scores\":[{\"score\":7.112266875518214,\"type\":\"exam\"},{\"score\":67.734668378287,\"type\":\"quiz\"},{\"score\":88.99855402666871,\"type\":\"homework\"}]},\r\n\t{\"_id\":35,\"name\":\"Synthia Labelle\",\"scores\":[{\"score\":27.22049103148209,\"type\":\"exam\"},{\"score\":31.28760039265919,\"type\":\"quiz\"},{\"score\":79.23285425688643,\"type\":\"homework\"}]},\r\n\t{\"_id\":36,\"name\":\"Eugene Magdaleno\",\"scores\":[{\"score\":73.055900093666,\"type\":\"exam\"},{\"score\":79.85621560462026,\"type\":\"quiz\"},{\"score\":66.09143669040472,\"type\":\"homework\"}]},\r\n\t{\"_id\":37,\"name\":\"Meagan Oakes\",\"scores\":[{\"score\":86.06759716616264,\"type\":\"exam\"},{\"score\":79.45097452834857,\"type\":\"quiz\"},{\"score\":28.41090281547689,\"type\":\"homework\"}]},\r\n\t{\"_id\":38,\"name\":\"Richelle Siemers\",\"scores\":[{\"score\":34.64373397163318,\"type\":\"exam\"},{\"score\":91.46799649446983,\"type\":\"quiz\"},{\"score\":56.12615074082559,\"type\":\"homework\"}]},\r\n\t{\"_id\":39,\"name\":\"Mariette Batdorf\",\"scores\":[{\"score\":0.04381116979284005,\"type\":\"exam\"},{\"score\":90.25774974259562,\"type\":\"quiz\"},{\"score\":65.88612319625227,\"type\":\"homework\"}]},\r\n\t{\"_id\":40,\"name\":\"Rachell Aman\",\"scores\":[{\"score\":84.53009035375172,\"type\":\"exam\"},{\"score\":25.25568126160764,\"type\":\"quiz\"},{\"score\":70.42062575402956,\"type\":\"homework\"}]},\r\n\t{\"_id\":41,\"name\":\"Aleida Elsass\",\"scores\":[{\"score\":28.02518041693717,\"type\":\"exam\"},{\"score\":95.25243105389065,\"type\":\"quiz\"},{\"score\":68.05980405338909,\"type\":\"homework\"}]},\r\n\t{\"_id\":42,\"name\":\"Kayce Kenyon\",\"scores\":[{\"score\":44.62441703708117,\"type\":\"exam\"},{\"score\":27.38208798553111,\"type\":\"quiz\"},{\"score\":97.43587143437509,\"type\":\"homework\"}]},\r\n\t{\"_id\":43,\"name\":\"Ernestine Macfarland\",\"scores\":[{\"score\":15.29147856258362,\"type\":\"exam\"},{\"score\":78.40698797039501,\"type\":\"quiz\"},{\"score\":31.03031764716336,\"type\":\"homework\"}]},\r\n\t{\"_id\":44,\"name\":\"Houston Valenti\",\"scores\":[{\"score\":98.06441387027331,\"type\":\"exam\"},{\"score\":0.8760893342659504,\"type\":\"quiz\"},{\"score\":15.2177618920215,\"type\":\"homework\"}]},\r\n\t{\"_id\":45,\"name\":\"Terica Brugger\",\"scores\":[{\"score\":42.1011312120801,\"type\":\"exam\"},{\"score\":41.73654145887228,\"type\":\"quiz\"},{\"score\":18.91287189072117,\"type\":\"homework\"}]},\r\n\t{\"_id\":46,\"name\":\"Lady Lefevers\",\"scores\":[{\"score\":16.89237820123443,\"type\":\"exam\"},{\"score\":65.97505910406456,\"type\":\"quiz\"},{\"score\":48.42527123437286,\"type\":\"homework\"}]},\r\n\t{\"_id\":47,\"name\":\"Kurtis Jiles\",\"scores\":[{\"score\":92.96916908741805,\"type\":\"exam\"},{\"score\":22.86854192921203,\"type\":\"quiz\"},{\"score\":31.89793879453222,\"type\":\"homework\"}]},\r\n\t{\"_id\":48,\"name\":\"Barbera Lippman\",\"scores\":[{\"score\":35.43490750932609,\"type\":\"exam\"},{\"score\":97.42074160188449,\"type\":\"quiz\"},{\"score\":74.1092960902528,\"type\":\"homework\"}]},\r\n\t{\"_id\":49,\"name\":\"Dinah Sauve\",\"scores\":[{\"score\":96.64807532447064,\"type\":\"exam\"},{\"score\":14.56470882270576,\"type\":\"quiz\"},{\"score\":72.00519420743191,\"type\":\"homework\"}]}\r\n] )\r\n<\/pre>\n<p>The script gives the below output.<\/p>\n<p><figure id=\"attachment_55844\" aria-describedby=\"caption-attachment-55844\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55844\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-3.jpg\" alt=\"Fig. 4: Database &amp; Collection creation\" width=\"849\" height=\"492\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-3.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-3-300x174.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-3-768x445.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-55844\" class=\"wp-caption-text\">Fig. 4: Database &amp; Collection creation<\/figcaption><\/figure><\/p>\n<h4>2.1.4 Check Mongo database and collection<\/h4>\n<p>If the script works well, the database and the collection will be shown in the Mongo Workbench. Using the <code>db.collection_name.find()<\/code> command the documents of a collection will appear as below.<\/p>\n<p><figure id=\"attachment_55845\" aria-describedby=\"caption-attachment-55845\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-4.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55845\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-4.jpg\" alt=\"Fig. 5: Mongo database &amp; collection\" width=\"849\" height=\"367\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-4.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-4-300x130.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-4-768x332.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-55845\" class=\"wp-caption-text\">Fig. 5: Mongo database &amp; collection<\/figcaption><\/figure><\/p>\n<p>Here the <code>exam_scores<\/code> collection has <code>50<\/code> sample documents (i.e. <em>records<\/em>).<\/p>\n<h4>2.1.5 cursor.batchSize() method<\/h4>\n<p>Now, go back to the Mongo shell and use the <code>batchSize(&lt;size_parameter&gt;)<\/code> method to display the specified number of documents.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Query 1<\/em><\/span><\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.exam_scores.find().batchSize(10)\r\n<\/pre>\n<p>This command sets the batch size to <code>10<\/code> for the results of a <code><a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/method\/db.collection.find\/#db.collection.find\" target=\"_blank\" rel=\"noopener\">find()<\/a><\/code> query. The <code>batchSize()<\/code> method does not change the output in the Mongo shell, which, by default iterate over the first <code>20<\/code> documents.<\/p>\n<p><figure id=\"attachment_55846\" aria-describedby=\"caption-attachment-55846\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-5.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55846\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-5.jpg\" alt=\"Fig. 6: Mongo database batchSize() method\" width=\"849\" height=\"366\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-5.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-5-300x129.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-5-768x331.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-55846\" class=\"wp-caption-text\">Fig. 6: Mongo database batchSize() method<\/figcaption><\/figure><\/p>\n<p>Do <strong>note<\/strong>, the <code><a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/method\/db.collection.find\/#db.collection.find\" target=\"_blank\" rel=\"noopener\">find()<\/a><\/code> method displays the output in a non-structured pattern. If developers want to display the output in an attractive structured pattern, they can append the <a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/method\/cursor.pretty\/\" target=\"_blank\" rel=\"noopener\"><code>pretty()<\/code><\/a> method to the <code>find()<\/code> query as shown below.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Modified Query 1<\/em><\/span><\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.exam_scores.find().batchSize(10).pretty()\r\n<\/pre>\n<p>The <code>pretty()<\/code> method modifies the output in an attractive way as shown below.<\/p>\n<p><figure id=\"attachment_55847\" aria-describedby=\"caption-attachment-55847\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-6.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55847\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-6.jpg\" alt=\"Fig. 7: Mongo database pretty() method\" width=\"849\" height=\"468\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-6.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-6-300x165.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-guide-6-768x423.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-55847\" class=\"wp-caption-text\">Fig. 7: Mongo database pretty() method<\/figcaption><\/figure><\/p>\n<p>That\u2019s all for this post. Happy Learning!!<\/p>\n<h2>3. Conclusion<\/h2>\n<p>In this tutorial, we learned about the <code>batchSize()<\/code> method of the Mongo database. Developers can download the sample commands in the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<h2><a name=\"projectDownload\"><\/a>4. Download the Eclipse Project<\/h2>\n<p>This was an example of the <code>batchSize()<\/code> method available in the Mongo database.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/MongoDbCursorbatchSizeMethod.zip\" target=\"_blank\" rel=\"noopener\"><strong>MongoDbCursorbatchSize()Method<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello readers, these days to increase the system performance it is important to retrieve the records from a database in batches. In Mongo world, it is pretty straightforward and in this tutorial, we will see the cursor.batchSize() method available in the Mongo database. Let&#8217;s study in brief the usage of this method. 1. Introduction If &hellip;<\/p>\n","protected":false},"author":119,"featured_media":36154,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1447],"tags":[1194,1708],"class_list":["post-55840","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mongodb","tag-mongodb","tag-mongodb-cursor-methods"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MongoDB batchSize() Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Hello readers, in this tutorial, we will see the cursor.batchSize() method available in the Mongo database.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MongoDB batchSize() Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Hello readers, in this tutorial, we will see the cursor.batchSize() method available in the Mongo database.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-02T09:00:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"MongoDB batchSize() Example\",\"datePublished\":\"2018-03-02T09:00:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/\"},\"wordCount\":1008,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"keywords\":[\"MongoDb\",\"MongoDB Cursor Methods\"],\"articleSection\":[\"MongoDB\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/\",\"name\":\"MongoDB batchSize() Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"datePublished\":\"2018-03-02T09:00:58+00:00\",\"description\":\"Hello readers, in this tutorial, we will see the cursor.batchSize() method available in the Mongo database.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Software Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MongoDB\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/mongodb\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"MongoDB batchSize() Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MongoDB batchSize() Example - Java Code Geeks","description":"Hello readers, in this tutorial, we will see the cursor.batchSize() method available in the Mongo database.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/","og_locale":"en_US","og_type":"article","og_title":"MongoDB batchSize() Example - Java Code Geeks","og_description":"Hello readers, in this tutorial, we will see the cursor.batchSize() method available in the Mongo database.","og_url":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-03-02T09:00:58+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"MongoDB batchSize() Example","datePublished":"2018-03-02T09:00:58+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/"},"wordCount":1008,"commentCount":1,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","keywords":["MongoDb","MongoDB Cursor Methods"],"articleSection":["MongoDB"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/","url":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/","name":"MongoDB batchSize() Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","datePublished":"2018-03-02T09:00:58+00:00","description":"Hello readers, in this tutorial, we will see the cursor.batchSize() method available in the Mongo database.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-batchsize-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Software Development","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/"},{"@type":"ListItem","position":3,"name":"MongoDB","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/mongodb\/"},{"@type":"ListItem","position":4,"name":"MongoDB batchSize() Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/55840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=55840"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/55840\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/36154"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=55840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=55840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=55840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}