Correct way to add index columns in greenDao?

I am creating a data model in greenDAO. This is the port of the iOS application that uses Core Data. In iOS, we use indexes (indexes?) To increase search performance in a table of 20 columns (properties), where 5 columns are often requested. I know that this leads to additional storage and provides slow write to the table.

Delving into the documentation, I came across the addIndex (Index index) method in Entity and the index () method in Property.PropertyBuilder . What is the correct way to add an index to Entity?

Entity entity = schema.addEntity("entity"); entity.setSuperclass("SuperClass"); entity.addIdProperty(); entity.addIntProperty("property").index(); 

or

 Entity entity = schema.addEntity("entity"); entity.setSuperclass("SuperClass"); entity.addIdProperty(); Property property = entity.addIntProperty("property").getProperty(); entity.setIndex(property); 

Or are they both doing the same thing?

+8
android orm greendao
source share
1 answer

Use myProperty.index () for individual property indices (because it is most convenient).

For more complex indexes, such as multi-column indexes, use addIndex (index):

 Index index = new Index(); index.addProperty(property1); index.addProperty(property2); entity.addIndex(index); 
+18
source share

All Articles