Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB find query with parameters loads whole document in memory or not?

Tags:

mongodb

In MongoDB, when we pass field names as the second parameter for find query does mongodb load whole document in memory or only the memory associated with those fields ?

like image 576
Ashish Avatar asked May 23 '12 12:05

Ashish


1 Answers

On the MongoDB server side, the whole document is stored in one place on disk. Because MongoDB use memory mapped files, any document access requires that whole document to be loaded in memory. After the query has run, only the requested fields are transferred to the client. This means that on the client/driver side, only the requested fields are stored in memory, and not the whole document

like image 172
Derick Avatar answered Dec 15 '22 00:12

Derick