When I fetch for records with fields that are Strings (or others) it takes under 1 second:
let query = CKQuery(recordType: "Messages", predicate: NSPredicate(format: "TRUEPREDICATE"))
NSLog("Started fetching")
self.publicDb.performQuery(query, inZoneWithID: nil) { (records, error) in
NSLog("Finished fetching")
print(records!.count)
}
But, when this record type contains a CKAsset, the time for the query goes up to at least 3 seconds. This is not acceptable when I want to load an image that is 100kb. It's the same when I put the asset in as a reference and load it from there. What can I do to speed up queries for records that contain assets or is there any other way to store assets in a more efficient way?
Use an operation and set the quality of service:
If you don't set qualityOfService, you will get the background level and it will be slow.