Re: Core Data dog-slow when using first time after boot
Re: Core Data dog-slow when using first time after boot
- Subject: Re: Core Data dog-slow when using first time after boot
- From: Ben Trumbull <email@hidden>
- Date: Thu, 3 Sep 2009 13:00:49 -0700
On Sep 3, 2009, at 4:49 AM, Ruotger Skupin wrote:
Since it's not a many to many, you can perform the prefetching
effectively by hand using a fetch request to preload the relevant
destination rows with an IN query based on the data you initially
fetched for the source entity. You shouldn't have to, but if
you've run into a bug, that's how you could workaround it.
You still haven't described the NSPredicate you were using with
filteredArrayUsingPredicate. Being more forthcoming about the
context and details of your problem will help us get you answers
more quickly.
This is the predicate I was using for the test of the original
post, but since I use Smart Folders predicates can look a lot
different (i.e.: complex):
(additionalInfo.onTheFlyIsInternal == 0 AND
additionalInfo.isSuppressed != 1) AND (account.uniqueID IN
{"D1AB3788-00DF-4475-A979-CE3EFC3987B5"} OR FALSEPREDICATE)
You'll want to prefetch additionalInfo and account.
Hm. Problem here is: As mentioned I use the predicate for a smart
group. So the predicate can vary wildly and can reference basically
any entity in the model. So what is the best strategy here?
"Decompile" the predicate (which is built by an NSPredicateEditor)
and prefetch the keypaths it takes? Prefetch "everything"?
Prefetching everything is usually undesirable. The easiest
approximate solution is to just track the hot button relationships for
each of your core entities, and look up which keypaths to prefetch by
entity name. Of course, you can also do a lot less filtering in
memory if you pass the predicates to the database with the fetch
request. You only need to prefetch relationships you are going to use
in memory. You don't need to prefetch anything that's simply used as
part of the predicate in the fetch request itself.
Walking through the predicate and gathering up the keypaths used is
very tedious, but not especially difficult, if you find yourself
wanting a complete solution.
- Ben
_______________________________________________
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