COLLATE to create Coredata INDEX

Short question:

Is there a way to tell CoreData to use COLLATE when creating an INDEX?

Detailed explanation:

I need to display a list of clients in a case insensitive list by name. The "name" field is marked for INDEXING in xCode. I use the following sort descriptor:

sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]; 

This leads to the following query from CoreData. All is good so far.

 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 when creating the INDEX. This would mean that all case-insensitive queries would be slow for a large dataset.

 CREATE INDEX ZCLIENT_ZNAME_INDEX ON ZCLIENT (ZNAME) 

Is there a way to create an index based on COLLATE? Is there a way to specify this in xCode?

+4
source share
1 answer

No. If you want to do this, write a request for improvement . You get extra bonus points from the CoreData team if you can include a sample project showing how COLLATE will do things superbly and surprisingly faster.

+3
source

Source: https://habr.com/ru/post/1335908/


All Articles