Reputation: 487
Short Question:
Is there a way to tell CoreData to use COLLATE while creating INDEX?
Detailed Explanation:
I need to show list of Clients in case insensitive sorted list by name. The "name" field is marked for INDEXING in xCode. I am using the following sort descriptor:
sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
This results in the following query from CoreData. All good till now.
SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZNAME FROM ZCLIENT t0 WHERE t0.Z_PK IN (?, ?, ?) ORDER BY t0.ZNAME COLLATE NSCollateLocaleSensitiveNoCase LIMIT 20
But if I look at the INDEX created by CoreData, it does not use COLLATE while creating INDEX. This would mean that all case insensitive queries would be slow for large data set.
CREATE INDEX ZCLIENT_ZNAME_INDEX ON ZCLIENT (ZNAME)
Is there a way to create a COLLATE based INDEX? Is there a way to specify that in xCode?
Upvotes: 4
Views: 1028
Reputation: 243156
No. If you'd like the ability to do so, please file an enhancement request. You get extra bonus points from the CoreData team if you can include a sample project showing how COLLATE would make things superbly and awesomely faster.
Upvotes: 3