Rashmi
Rashmi

Reputation: 11

Multiple realm for multiple objects in an iOS app

We have number of objects in our iOS app with close references to each other to nested levels. Our app is heavily multi-threaded. With realm(Objective C) as database choice, following questions have come up and looking forward to answers:

  1. Should we go with single realm or multiple realm, one for each object?
  2. Do we need to bother about low memory issue, for both single/multiple approaches? Please note we have thousands of objects to deal with and will be using realm persisted on disk.
  3. Do we need to be worried about growing realm size with thousands of objects? If we go with multiple realm, will it work for chained queries from multiple realms?
  4. Any best practices/constraints to consider for accessing objects from multiple realms? How to handle multi threading with multiple realm files? Does it need special treatment than multi threading with single realm?

Upvotes: 1

Views: 1112

Answers (1)

bmunk
bmunk

Reputation: 1578

The short answer is that you should use one Realm. A Realm is a file with a bunch on objects and relations. It's not possible to query across multiple Realms. So only split up in multiple Realms if your objects are not related at all and you don't have relations to objects in other Realms. Thousands of objects is no problem at all.

Upvotes: 1

Related Questions