In my model, I set Entity (let's say Person) to have an attribute in the form of a string (called "name"), and I put an index on it. If I ask a lot of queries on my model, the queries go beyond performance. My request is simple
[ NSPredicate predicateWithFormat: @"%K == %@", @"name", lPersonName ];
therefore, I would suggest that the index do its job.
Then, if I compute some simple hash tag and store it along with my entity in an indexed integer attribute (called a hash) and make a narrower query, performance loss is reduced. Like this:
[ NSPredicate predicateWithFormat: @"%K == %d AND (%K == %@)", @"hash", [ self calculateHashForName: lPersonName ], @"name", lPersonName ];
Why is an index on integers much faster than an index on a string? Am I missing something? Is this a problem with master data?
I can save the solution with a hash tag, of course, but if I miss something, I would like to know about it sooner rather than later.
source share