Search code examples
iosrealm

Character count limitation for primary key


Hi is there any characters count limitation for primary key in Realm? like cannot exceed 255 characters.


Solution

  • Realm currently has a hard limit on strings of 16MB. There's no separate limit for indexed fields, including primary keys, at this time. That said, the string index format Realm uses works best when the indexed values do not have long common prefixes. For that reason I'd advise limiting your primary key, and other indexed string fields, to less than 512 bytes.