2

I have used Realm DB in my app for the last two years. Up to now, it is working fine. Now for an upgrade to my app during app startup, I need to insert close to 100k entries to Realm DB from JSON. In this case, it took 30 seconds to insert. I cant navigate users to the home page without this data. I don't want the app users to wait for so long during app startup. Tried Android Room DB, which is slower than Realm. Then tried ObjectBox, which does the same job in 2 to 3 seconds, which is excellent. But I want to know the stability and reliability of ObjectBox. Are any big companies using it? Or any alternative suggestions for this case?

Below is my code

//MyDataList contains 100k objects
Realm.getDefaultInstance().run {
            executeTransaction {
                it.delete(MyData::class.java)
                it.insert(MyDataList)
            }
            close()
        }
Bala Pravin
  • 101
  • 5
  • Are you running your inserts in a transaction? For both Realm and Room, that'll give you a huge performance difference. – ianhanniballake Jul 15 '22 at 05:45
  • Yes, inside transaction only. – Bala Pravin Jul 15 '22 at 06:20
  • Asking for opinions about 3rd party products is generally off topic for SO; the reason is that without understanding the entire use case, any answers, however compelling could an opinion without direct knowledge of your use case. Our Realm files are massive 2G+ so 100,000 objects isn't really a large dataset. Part of your issue could be coding problem, or perhaps delays in actually retrieving or working with the JSON objects - not saying it is, but it *could be*. SO is better suited for coding specific issues and recommending products. Post your code, describe the issue and we'll take a look. – Jay Jul 15 '22 at 18:20
  • @Jay Added my code – Bala Pravin Jul 17 '22 at 12:45
  • The code lacks context; why Delete? What do the Realm objects look like? What is `MyDataList`? What's the use case? e.g. Attempting to keep 100k 16Mb Objects in *memory* would overwhelm the devices capacity and would be slow due to disk swapping. Is that code on the main thread instead of background? If the exact same task can be done using ObjectBox then why ask the question (please don't ask for opinions on SO)? If you want help with your Realm code though we're happy to help. Please post a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve)so we can take a look. – Jay Jul 17 '22 at 13:45

1 Answers1

1

I think ObjectBox is a perfectly fine choice, especially for your performance-heavy use case. The project is actively maintained and the first version recommended for productive use was already released in 2017. Today, over 1 Mill developers have started building with ObjectBox.

CallApp is a notable company that uses ObjectBox, as of February 2021 has over 100 Mill users.

DISCLAIMER: I just started working at ObjectBox team, so I am a little biased.