Realm sync: Collection priorities when opening in background?

We are syncing about 40 collections from Atlas, some of the rather large with about 100.000 documents. Depending on network latency and connection speed, initial sync is between 30 seconds to 10 minutes. The collections are using relationships extensively.

I’d like to change this to sync in background so the app can open without waiting for the full download. However, data seem to sync randomly leading to a bad user experience as linked objects may or may not be available.

I was hoping I could priority my collections in the sync configuration but no option like that exists. Similar to the timeout option but forcing some collections to be fully downloaded and others async in background. Or setting some limits per collection, like top N documents to start with, rest in background.

How should we approach this? Any design patterns to investigate?

The obvious solution is splitting to different Realms. However, the app developers are very happy with the relationships within a single Realm that then would be lost.

There is no way to assign priorities to different collections unfortunately and for partition based sync it will likely never be an option due to its design. It is definitely a possible future improvement for flexible sync so we can keep that in mind. It actually would be possible already in flexible sync by just opening your subsciptions one at a time, so perhaps its work looking into that?

The other option for this would be to use embedded objects instead of linking objects. This would effectively solve your problem, but I realize that linking objects may be integral to your application’s design.

Yes, flexible sync would solve it. Awaiting a production release! :slight_smile:

Flexible sync would also benefit from being able to specify a sort order along with the filter but is less important there.