M
M
mmmq2020-10-17 12:02:45
Node.js
mmmq, 2020-10-17 12:02:45

How to work with big data in MongoDB?

Hello.

Faced a problem when requesting data over 2000, the response starts to slow down. From 3 thousand records, everything dies without an answer. It's not even "big data", so I don't understand how to solve this problem. I am using Mongoose to make queries.

ps Perhaps not the correct database architecture.

Request:

const candles = await candlesModel.findOne({ symbol, interval }).then(res => res.data)


Document structure in the "candles" collection:

{
_id: 'ObjectID',
symbol: 'BTCUSD',
interval: '2h',
data: [ {open, high, low, close, timestamp}, ... ]
}


This solution was chosen because of the large number of symbols and different intervals. data contains the main array of data for a symbol (from 2000 thousand)

Hardware:

I use the basic tariff MongoDB Atlas 500md RAM server (only local development).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Philipp, 2020-10-19
@mmmq

Cursors should be used to work with data correctly.
You need something like this .
There is no error, most likely due to running out of memory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question