Reputation: 55
I am using MongoDB in our project and I'm currently learning how things work
I have created a collection with 5 million records. When i fire the query db.ProductDetails.find()
on the console it takes too much time to display all the data.
Also when i use the following code in C#
var Products = db.GetCollection("ProductDetails").FindAll().Documents.ToList();
the system throws OutOfMemoryException
after some time..
Is there any other faster or more optimized way to achieve this ?
Upvotes: 4
Views: 6280
Reputation: 1
Try to get the subset which is needed. If you try to fetch all objects, then it is for sure you will need enough RAM as the size of your database collection !! Try to fetch the objects which will be used in the application.
Upvotes: 0
Reputation: 101192
Never try to fetch all entries at the same time. Use filters or get a few rows at a time.
Read this question: MongoDB - paging
Upvotes: 4