ObjectBox is a high-performance NoSQL database optimized for mobile and edge devices. Unlike SQLite, it uses its own flat-file storage format without an SQL layer. According to ObjectBox Benchmarks, 2024, ObjectBox performs insert and read operations 10–100 times faster than SQLite on Android devices, making it the best choice for high-load mobile applications.
Key Takeaways
ObjectBox is an in-memory NoSQL database developed by the German company ObjectBox.io. Unlike traditional relational databases, ObjectBox stores objects directly in flat files using its own SLOT (Super Lightweight Object Tree) format. This eliminates the overhead of ORM and SQL parsing. The SLOT format is optimized for devices with limited memory: data is defragmented automatically, and the database size is on average 4–6 times smaller than an equivalent SQLite database with the same number of records.
ObjectBox supports all major mobile platforms: Android, iOS and Flutter. For Android, code generation is available via the ObjectBox Gradle Plugin, which processes annotated entities and creates Box classes for working with data. For Flutter, a native plugin with a Dart wrapper is used. In addition to mobile platforms, ObjectBox runs on Linux, macOS, Windows and WebAssembly, allowing you to reuse the data model between the mobile app and server synchronization.
According to an ObjectBox study (2023), the database is used in more than 5,000 applications on Google Play, including apps with over 10 million users. Main use cases: data caching, offline operation, and time-series storage (IoT). ObjectBox is especially popular in health and fitness tracking apps that require fast recording of sensor readings on the device without a constant internet connection and for collecting analytics from multiple devices.
ObjectBox emerged as an alternative to Realm and SQLite for the Android platform. The first stable version was released in 2018. The key difference from Realm is that ObjectBox has no GPL restrictions (uses Apache 2.0) and supports more platforms: from mobile devices to Linux servers.
ObjectBox provides: automatic Box class generation, built-in indexes for fast search, transactions with rollback support, reactive queries via RxJava and Kotlin Flow, and device-to-device synchronization via ObjectBox Sync (proprietary protocol). Unlike Firebase Realtime Database, ObjectBox Sync works on a peer-to-peer model without a central server, reducing latency and infrastructure costs.
ObjectBox stores data in its own binary format .mdb (ObjectBox Data File). Each entity is mapped to one file, where records are stored sequentially with a fixed offset. This allows reading and writing individual objects without full file scanning.
Working with ObjectBox does not require SQL: queries are built via a fluent API in code. The compiler generates helper classes MyObjectBox and Boxes that encapsulate all CRUD operations. The data model is described using annotations @Entity, @Id, @Index and @Relation.
// Connecting ObjectBox in Android
class App: Application() {
lateinit var boxStore: BoxStore
override fun onCreate() {
super.onCreate()
boxStore = MyObjectBox.builder()
.androidContext(this)
.build()
}
}
According to official benchmarks, ObjectBox significantly outperforms SQLite in speed, especially in batch inserts and mass reads. However, SQLite remains the de facto standard for mobile applications due to its prevalence and built-in SQL support.
| Operation | ObjectBox | SQLite | Difference |
|---|---|---|---|
| Insert (1000 records) | ~5 ms | ~180 ms | x36 faster |
| Read (1000 records) | ~3 ms | ~70 ms | x23 faster |
| Update (1000 records) | ~6 ms | ~150 ms | x25 faster |
| Index search | ~0.1 ms | ~2 ms | x20 faster |
| DB size (1000 objects) | ~28 KB | ~112 KB | 4 times smaller |
ObjectBox falls short of SQLite in scenarios that require complex JOIN queries, aggregate functions (SUM, COUNT with grouping), or integration with an existing SQL schema. If the project already uses SQLite with Room ORM, migrating to ObjectBox will require rewriting all data access logic. ObjectBox also does not support custom SQL queries — only fluent API. However, for typical CRUD operations and caching, ObjectBox provides up to 100x performance improvement, as confirmed by official benchmarks on Android devices with different OS versions.
ObjectBox uses annotations to define entities. After compilation, Box classes are created with put, get, remove and query methods. Below are typical operations for a Task model in a to-do list app.
Each entity is annotated with @Entity. A field with @Id becomes the primary key, and @Index speeds up searches on that field. ObjectBox supports automatic ID generation when the value is 0.
@Entity
data class Task(
@Id var id: Long = 0,
@Index var title: String = "",
var isCompleted: Boolean = false,
var priority: Int = 0
)
Box is the main class for working with entities. The put() method saves or updates an object, get() reads by ID, and remove() deletes. All basic operations are synchronous and execute on the calling thread.
val taskBox: Box<Task> = boxStore.boxFor(Task::class.java)
// Create
val task = Task(title = "Buy products", priority = 3)
val newId = taskBox.put(task)
// Read
val savedTask = taskBox.get(newId)
// Update
savedTask.isCompleted = true
taskBox.put(savedTask)
// Delete
taskBox.remove(newId)
ObjectBox supports reactive queries via .subscribe(). The subscriber receives notifications whenever data matching the query condition changes. This is convenient for UI that automatically updates the list when items are added or removed.
val query = taskBox.query()
.equal(Task_.isCompleted, false)
.orderDesc(Task_.priority)
.build()
query.subscribe { tasks ->
// tasks — List, updates automatically
updateUi(tasks)
}
ObjectBox supports relationships between entities — To-One, To-Many and Many-to-Many. Relationships are defined via the @Relation annotation. Unlike SQLite, ObjectBox does not use foreign keys: relationships are implemented through ID lists in flat files, which speeds up graph traversal of objects.
The @Backlink relationship allows traversing from a child entity to its parent without a separate reference field. ObjectBox automatically maintains the backlink, eliminating data duplication and synchronization between two tables.
ObjectBox Query Builder allows building chains of conditions: equal, notEqual, greater, less, in, contains, startsWith. All conditions can be combined via and/or. The result can be sorted, limited, and retrieved as a List or LazyList (for large datasets).
ObjectBox automatically indexes the @Id field. For custom indexes, use the @Index annotation on fields that are frequently queried. Indexes speed up equal and in queries but slow down inserts — do not index fields that are not searched. ObjectBox supports composite indexes for filtering by multiple fields simultaneously. Composite indexes are especially useful for list filters: for example, searching for incomplete tasks with high priority is tens of times faster with a composite index on the isCompleted and priority fields.
ObjectBox Sync is a proprietary technology for real-time data synchronization between devices. It uses a WebSocket-based protocol with conflict resolution by last-writer-wins. Sync is suitable for apps that need offline synchronization: notes, task lists, IoT data from multiple sensors. However, a license purchase is required for production.
// Query with multiple conditions
val highPriorityIncomplete = taskBox.query()
.greater(Task_.priority, 5)
.equal(Task_.isCompleted, false)
.build()
.find()
// Substring search
val searchResults = taskBox.query()
.contains(Task_.title, "product", StringOrder.CASE_INSENSITIVE)
.build()
.find()
Frequently Asked Questions
ObjectBox is distributed under the Apache 2.0 license, which permits commercial use without restrictions. The ObjectBox Sync feature (cross-platform synchronization) is proprietary and requires purchasing a license for production.
BoxStore is thread-safe: multiple threads can read data simultaneously. Writes are locked at the Box level. For complex transactions use boxStore.runInTx(), which guarantees atomicity of a group of operations.
Yes, ObjectBox supports Kotlin Multiplatform (KMP) starting from version 3.0. Targets Android, iOS, JVM and Native are available. For KMP, a separate Gradle plugin objectbox-kotlin with expect/actual support is used.
ObjectBox stores data in .mdb files in the app directory. For backup, copy the entire ObjectBox directory via BoxStore.copy() or manually copy the files after calling boxStore.close(). Live files cannot be copied — this will corrupt the data.
Room is an ORM on top of SQLite, requires SQL queries and has object mapping overhead. ObjectBox is a NoSQL database without SQL, an order of magnitude faster, but does not support complex JOINs and is not a relational database. The choice depends on the task: for relational data — Room, for fast object storage — ObjectBox.
Summary
We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also