I used to be load testing my app that lists some todos and basically pre-populated database with 1000 data. This slowed issues down within the app dramatically, tab switching felt sluggish and I pinpointed it right down to utilizing
@Question var todos: [Todo]
Nevertheless if I change this question with a computed property that makes use of FetchDescriptor i.e.
var todos: [Todo] {
var descriptor = FetchDescriptor<Todo>()
do { return strive DatabaseContainer.mainContext.fetch(descriptor) }
catch { return [] }
}
All the things is abruptly tremendous quick (albeit observable nature of question is misplaced). Why is there such a drastic efficiency distinction?
@Question
– takes ~2-3s to resolve
FetchDescriptor
– is instantaneous
Is that this a identified limitation / bug in SwiftData?