• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CoreData fetch is way too slow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData fetch is way too slow


  • Subject: Re: CoreData fetch is way too slow
  • From: Phil <email@hidden>
  • Date: Tue, 5 Feb 2008 14:52:15 -0500

On Feb 5, 2008, at 2:31 PM, James Hober wrote:

I have a CoreData app that has a SQLite store holding 157,273 managed objects. Each managed object has 2 attributes, input and answer, which are NSStrings and that's all. No other attributes. No relationships. No fetched properties.

A simple fetch for a single managed object takes 7 seconds!

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@",
@"input", input]; //assume NSString *input exists

Two things come to mind:
First, make sure that 'input' is indexed.
Second, be careful of how/when you use 'like' in your predicates as it is pretty easy to take a huge performance hit (this is true even when using straight SQL) as you can have a clause that requests "input like '%sometext'" which can't make use of an index and you'll force a full table scan.


I found Ben's response to one of my posts a few weeks back quite helpful: http://www.cocoabuilder.com/archive/message/cocoa/2008/1/16/196552

Phil
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >CoreData fetch is way too slow (From: James Hober <email@hidden>)

  • Prev by Date: Re: Setting an NSColor crashes - probably very simple issue
  • Next by Date: Re: CoreData fetch is way too slow
  • Previous by thread: Re: CoreData fetch is way too slow
  • Next by thread: Re: CoreData fetch is way too slow
  • Index(es):
    • Date
    • Thread