Replies: 1 comment
-
What do you mean by "not using () on the declaration of collections"? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to know how the performance of Realm's
Map
type compares to the performance of just usingfilter
on aList
.For example, suppose I have a model where I have 400,000
FileItem
instances (a subclass ofObject
), each of which represents a file on disk. I need to quickly get theFileItem
object for path/some/file/path.txt
. Which route is more performant:Create a
Map<String: FileItem>
property, where the key is the path of each file?Create a
List<FileItem>
property and then just use.where({ $0.path == somePath })
?General Observation
There's often very little documentation about the best performance path in Realm. There's a few tricks, like not using
()
on the declaration of collections, and structuring filter closures so that the most performant checks come first (e.g. numbers before strings), but there's lot of situations like the above where I wonder how things work under the hood.Where the Swift SDK hits Realm Core, is the
Map
object just a convenient "wrapper" around the same database queries thatfilter
will generate? Or isMap
, likeDictionary
, actually an optimized data structure for random access by key?I wish the docs would offer more information about performance and how to maximize it. It's hard to implement a complex app multiple ways to discover performance by testing.
Beta Was this translation helpful? Give feedback.
All reactions