title: How to speed up Cloudkit 'fetchRecordWithID'
body: <p>The first operation that my app does when It's open for the first time Is to check at cloudkit if there is any information connected to the user iCloud account, because if there is, the information is downloaded to the app. My problem is that the method that download the information takes about 13 seconds to collect the information when it's connected over wifi and takes OVER 45 SECONDS when using mobile data. I was looking for optimization and discovered that when simulating using the <code>development</code> database the results are faster that simulating with the <code>produciton</code> database, so I probably am collection the data in the wrong way, since there is a lot of more data at the production thant the development.</p>
  
  <p>The method the search to the info looks like this</p>
  
  <pre><code>CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName: userKey];
  
  [_publicDatabase fetchRecordWithID:recordID completionHandler:^(CKRecord * _Nullable record, NSError * _Nullable error) {
          if (error) {
              NSLog(@"Error in fethcing from user db %@", error);
              completion(error);
          } else {
  
              NSLog(@"User found in db");
              NSString *name = record[@"Name"];
              CKAsset *file = record[@"Image"];
              NSString *url = file.fileURL.absoluteString;
              NSMutableArray&lt;NSString*&gt; *codes = record[@"Groups"];
  
              NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
              NSString * basePath = ([paths count] &gt; 0) ? [paths objectAtIndex:0] : nil;
              NSData * binaryImageData = [NSData dataWithContentsOfURL:[file fileURL]];
              [binaryImageData writeToFile:[basePath stringByAppendingPathComponent:@"profilePicture.png"] atomically:YES];
  
              completion(nil);
          }
  
      }];
  </code></pre>
  
  <p>The information at the cloud are basically the name, profile picture and the groups codes.</p>
  
  <p>There is a way to speed up this fetch from cloudkit? Because i dont thing that is normal to take over 45 seconds the fetch this data over mobile data, this doesnt make sense.</p>