Should I be using @Index with Realm?
I have max. 600,000 objects in my database. I am making queries on id (int) =, uuid = and time (int) <= and the results are ordered by time. Should I use @Index annotation for some fields and maybe change the id from Integer to String? Will the queries be slow because I cannot index the time field and cannot have multiple index of the field? Will Sqlite better suit my need?
Also, if I store a large number of objects in the database at the same time, should I use one transaction for all objects or create a new transaction for each object? How much memory will a large transaction consume and is there performance when creating a new transaction for each object?
The database will reside in the external storage (memory card) of the Android device.
source to share
Kingdom Christian is here. As for @Index, we'll add it for integers shortly. If you are concerned about speed, I would probably check the various options to see which approach works best for you, as the answers to these questions are quite complex in general.
From a transactional perspective, it is generally faster to unload as much as possible within a single transaction, since there is overhead associated with creating and committing a transaction, but everything inside a transaction must match memory. Therefore, depending on how large the dataset is, it may have to be split into smaller batches. Again, creating a small proof of concept is probably the best approach to see what works best in your particular case.
source to share