antoniopresto / react-native-local-mongodb

react-native local mongodb storage.
MIT License
303 stars 66 forks source link

Find method performance in debugging mode #65

Closed nuvolarmobileteam closed 2 years ago

nuvolarmobileteam commented 5 years ago

Hello everyone!

I'm using this library and it is been working great while I have been testing it out but I'm running into an issue now. I'm running this in the iOS simulator and if I use inMemoryOnly option everything is perfect.

I have 6 small collections. All of them contain very few data. When the in memory option is false and I use find on the biggest collection (380 documents - 150Kb) it takes around 9 seconds to return the results in debugging mode and 3 seconds if I am not debugging.

I was not expecting this query to take this long. Am I wrong?

This is the code I that is taking this long: db.find({}, {}, (err: Error, docs: MongoDocument[]) => {}

Any clue on why it is taking 3 to 9 seconds in this simple query?

The update is perfectly fine. Is fast. I have tried both AsyncStorage, the one included in react native core and the new community version.

Thanks a lot in advance

antoniopresto commented 5 years ago

And without debug mode?

nuvolarmobileteam commented 5 years ago

Hi @antoniopresto Without debug mode it takes 3s.

antoniopresto commented 5 years ago

probably the problem is asyncStorage, it tends to be slow. try using custom storage: https://github.com/antoniopresto/react-native-local-mongodb#using-a-custom-storage