- Is not an ORM or built on top of SQLite, it has its own database engine and doesn’t just rely on key-value stores.
- Developers prefer to use it while handling a large amount of data or for high-performance applications.
- Allows developers to undergo frequently mapping classes, tables, foreign keys or the fields.
- Is a local database, when combined with a server-side database such as MongoDB, DynamoDB or MYSQL; developers can easily interact with the data synced locally in the Realm database.
- Is offline friendly with redux-offline.
- Databases have been proven to run queries and sync objects significantly faster than SQLite and others.
- Was built from ground up for mobile, so they had the privilege to go beyond the traditional norms(SQLite).
Apart from offline synchronization, Realm also offers the following offline features as well
- Synchronization services run in the background to record and save the user interaction, and service requests locally. Once the device is online, it sends data back to the server and executes the tasks without hindering the user experience.
- It has algorithms in place to handle the conflicts in the objects while syncing the data back to the server.
- Offline queue support automatically re-dispatch user actions when the connection is back online.
Performance of Realm
- Built-in storage engine written in C: Reduces dependencies and improves query performance.
- The traditional SQLite with ORM abstraction is leaky because ORM simply converts Objects and their methods into SQL statements. Realm, on the other hand, is an object database, meaning your objects directly reflect your database and it doesn’t convert the objects while doing read/write operations.
- Zero-copy: The traditional way of reading data from a database leads to unnecessary copying into language level objects. Realm avoids this by mapping the whole data in-memory, using B+ trees and whenever data is queried, Realm simply calculates the offset, reads from the memory mapped region and returns the raw value.
- Concurrency Control: Realm smoothly handles the concurrency using the MVCC model, which means that multiple read transactions can be done at the same time and reads can also be done while a write transaction is being committed.