FROM : Phil
DATE : Tue Feb 05 20:52:15 2008
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
DATE : Tue Feb 05 20:52:15 2008
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
| Related mails | Author | Date |
|---|---|---|
| James Hober | Feb 5, 20:31 | |
| Mike Glass | Feb 5, 20:44 | |
| Phil | Feb 5, 20:52 | |
| Bill Dudney | Feb 5, 20:58 | |
| Ben Trumbull | Feb 6, 01:07 | |
| James Hober | Feb 6, 19:24 |






Cocoa mail archive

