Ashish
Ashish

Reputation: 363

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

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 ?

Upvotes: 6

Views: 1274

Answers (1)

Derick
Derick

Reputation: 36794

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

Upvotes: 5

Related Questions