title: How to improve NSFetchedResultsController performFetch: performance?
body: <p>I have only 3237 records in the database and I used UISearchDisplayController and NSFetchedResultsController for search. but when I type the keyword for search it's extremely slow:</p>
  
  <pre><code>2012-06-26 10:26:25.264 KYBD[3863:707] CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZARTICLEPARTCHINESE, t0.ZARTICLEPARTENGLISH, t0.ZARTICLEPARTNUMBER, t0.ZARTICLE FROM ZARTICLECONTENT t0 LEFT OUTER JOIN ZARTICLES t1 ON t0.ZARTICLE = t1.Z_PK WHERE ( NSCoreDataStringSearch( t0.ZARTICLEPARTENGLISH, ?, 257, 0) OR  NSCoreDataStringSearch( t0.ZARTICLEPARTCHINESE, ?, 257, 0)) ORDER BY t1.ZARTICLETITLE, t0.ZARTICLEPARTNUMBER
  2012-06-26 10:26:26.438 KYBD[3863:707] CoreData: annotation: sql connection fetch time: 0.5325s
  2012-06-26 10:26:26.446 KYBD[3863:707] CoreData: annotation: total fetch execution time: 1.1821s for 2549 rows.
  2012-06-26 10:26:26.489 KYBD[3863:707] CoreData: sql: SELECT  t1.ZARTICLETITLE, COUNT (DISTINCT  t0.Z_PK) FROM ZARTICLECONTENT t0 LEFT OUTER JOIN ZARTICLES t1 ON t0.ZARTICLE = t1.Z_PK WHERE ( NSCoreDataStringSearch( t0.ZARTICLEPARTENGLISH, ?, 257, 0) OR  NSCoreDataStringSearch( t0.ZARTICLEPARTCHINESE, ?, 257, 0)) GROUP BY  t1.ZARTICLETITLE ORDER BY t1.ZARTICLETITLE
  2012-06-26 10:26:26.874 KYBD[3863:707] CoreData: annotation: sql connection fetch time: 0.3733s
  2012-06-26 10:26:26.879 KYBD[3863:707] CoreData: annotation: total fetch execution time: 0.3904s for 100 rows.
  </code></pre>
  
  <p>My NSFetchedResultsController code:</p>
  
  <pre><code>- (NSFetchedResultsController *)fetchedResultsController {
      if (!_fetchedResultsController) {
          NSFetchRequest *request = [[NSFetchRequest alloc] init];
          request.entity = [NSEntityDescription entityForName:@"ArticleContent" inManagedObjectContext:self.managedObjectContext];
          NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"article.articleTitle" ascending:YES];
          NSSortDescriptor *sort2 = [NSSortDescriptor sortDescriptorWithKey:@"articlePartNumber" ascending:YES];
          request.sortDescriptors = [NSArray arrayWithObjects:sort, sort2, nil];
          request.predicate = nil;
  
          [NSFetchedResultsController deleteCacheWithName:@"searchResults"];
          _fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"article.articleTitle" cacheName:@"searchResults"];
      }
  
      return _fetchedResultsController;
  }
  </code></pre>
  
  <p>and the code for search:</p>
  
  <pre><code>- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
      if ([searchString length] &gt; 0) {
          [NSObject cancelPreviousPerformRequestsWithTarget:self.fetchedResultsController selector:@selector(performFetch:) object:nil];
          NSPredicate *predicate = [NSPredicate predicateWithFormat:@"articlePartEnglish CONTAINS[c] %@ OR articlePartChinese CONTAINS[c] %@", searchString, searchString];
          self.fetchedResultsController.fetchRequest.predicate = predicate;
          [NSFetchedResultsController deleteCacheWithName:@"searchResults"];
          [self.fetchedResultsController performFetch:nil];
  
      }
  
      return YES; 
  }
  </code></pre>
  
  <p>Is there any problem? and how could I improve the performance?
  Best regards.</p>