realm / realm-kotlin

Kotlin Multiplatform and Android SDK for the Realm Mobile Database: Build Better Apps Faster.
Apache License 2.0
962 stars 61 forks source link

RealmKotlin.copyToRealm magnitures slower than RealmJava.insertOrUpdate #1827

Open BlueCobold opened 2 months ago

BlueCobold commented 2 months ago

How frequently does the bug occur?

Always

Description

I have migrated from RealmJava 10.16.0 to RealmKotlin 1.16.0 and I have a piece of conversion code which creates RealmObjects from my model classes and then used insertOrUpdate to update the realm file. However, after migrating to RealmKotlin, I tried using copyToRealm with UpdatePolicy.ALL. And I also tried to sequentially query and update all the properties of the existing RealmObjects in my db with the values of my model files and in both cases, the time it takes to update all the objects (quite a lot) increased from ~2 seconds to about 20-40. This is a significant increase in execution time. The issue does not exist on RealmSwift either.

I am a bit helpless here at the moment, because I don't want to be stuck with RealmJava for too long anymore, but this issue is blocking a migration effectively.

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

Fetch all objects from the realm including nested/children, then deep-clone the objects and call a copyToRealm(data, UpdatePolicy.ALL) in a new write-block.

Version

1.16.0

What Atlas App Services are you using?

Local Database only

Are you using encryption?

Yes

Platform OS and version(s)

Android any

Build environment

Android Studio version: 2023.3.1 Android Build Tools version: 34 Gradle version: 8.4

sync-by-unito[bot] commented 2 months ago

➤ PM Bot commented:

Jira ticket: RKOTLIN-1124

BlueCobold commented 2 months ago

Looks like this is only happening with attached debugger. I'm calling this closed, but it is still very inconvenient.