100k inserts in Realm is slow, taking 30 seconds. Shall I use ObjectBox?

824 views Asked by At

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()
        }
1

There are 1 answers

3
Vahid Nesro On

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.