Tuesday, July 9, 2024
HomeiOS Developmentios - Why is SwiftData @Question a lot slower with giant datasets...

ios – Why is SwiftData @Question a lot slower with giant datasets in comparison with FetchDescriptor?


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?



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments