Answer the question
In order to leave comments, you need to log in
What strategy should be used in case of a huge amount of data?
So, there is a MongoDB base, on the NodeJs backend, connection to the base through the mongodb driver. The user at the front is allowed to make any selection. If the amount of data is too large, node.js will crash with the following error:
>> FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
>> Exited with code: 3.
>> Error executing child process: Error: Process exited with code 3.
Answer the question
In order to leave comments, you need to log in
1. First, count ONLY the NUMBER of records: COUNT
2. To select with the required data, use the constraint: LIMIT
Ptolemy_master , can get a separate column, where to indicate the amount of data in the column? That. you will be told how much data is accumulated for output. And accumulate the output until it exceeds the threshold.
Unfortunately, this is not possible in the database itself, since this is not our database, but clients. It is possible, of course, to start a separate collection in our database with this meta-information, but it is very expensive. For the time being, we decided to simply limit the sample size.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question