If I index a property and in the query I don't use the orderBy clause will the index be used ?
Example code:
DBIndexDefinition* index = [[DBIndexDefinition alloc] init];
[index addIndexForProperty:@"prop1" propertyOrder:DBIndexSortOrderAscending | DBIndexSortOrderDescending | DBIndexSortOrderNoCase secondaryProperty:@"prop2" secondaryOrder:DBIndexSortOrderAscending | DBIndexSortOrderDescending | DBIndexSortOrderNoCase];
prop1 and prop2 are of type NSString.
Thank you!
If I can just take your example above, you can only specify one order, unfortunately they are not bitwise operators.
DBIndexDefinition* index = [[DBIndexDefinition alloc] init];
[index addIndexForProperty:@"prop1" propertyOrder:DBIndexSortOrderAscending secondaryProperty:@"prop2" secondaryOrder:DBIndexSortOrderAscending];
Then, if you omit the orderby clause then, unfortunately you are at the mercy of SQLite utilising the index when performing the query. There is nothing added to DBAccess that allows you to specify an index for results.
You can, use the profiling to see which index was used by the query and that will tell you what optimisations SQLite made.