Index a Property - React Native SDK
On this page
Overview
Realm supports indexing for string, integer, boolean, Date
, UUID
, and ObjectId
properties. To define an index for a given property, set indexed
to
true
.
Note
An index significantly increases the speed of certain read operations at the cost of slightly slower write times and additional storage and memory overhead. Realm Database stores indexes on disk, which makes your realm files larger. Each index entry is a minimum of 12 bytes. The ordering of the index entries supports efficient equality matches and range-based query operations.
It's best to only add indexes when optimizing the read performance for specific situations.
Example
The following Book
object schema defines an index on the name
property.
const BookSchema = { name: "Book", properties: { name: { type: "string", indexed: true }, price: "int", }, };