JP Hribovsek
JP Hribovsek

Reputation: 6707

multi-column indexing in Core Data (iOS)

I remember reading somewhere about multi-column indexing in Core Data (iOS), but I can't find that information anywhere.

Is multi-column indexing possible with iOS5 Core Data?

I can set up multiple indexes on single columns, but can't find an option for multi-column index.

Upvotes: 2

Views: 2725

Answers (2)

JP Hribovsek
JP Hribovsek

Reputation: 6707

I found what I was looking for in WWDC 2011 videos, what's new in Core Data (iOS5).

They call this "compound indexes", and they are set by selecting the entity in XCode, you then have an "Indexes" field in the inspector when you can set what looks to be a multi column index: "attribute1,attribute2".

I just tested it, and it does work, so multi column index IS supported since iOS5

Upvotes: 6

Mundi
Mundi

Reputation: 80271

CoreData has no affordance for the creation or use of multi-column indices. This means that when you execute the query corresponding to your multi-property predicate, CoreData can only use one index to make the selection. Subsequently it uses the index for one of the property tests, but then SQLite can't use an index to gather matches for the second property, and therefore has to do it all in memory instead of using its on-disk index structure.

Source

Upvotes: -4

Related Questions