Well, like the title says, i got some performance problems while executing queryForAll on a DAO object with ormLite (with android, if it should matter).
The only thing i am actually doing is to execute this:
this.getHelper().getActivityDao().queryForAll(); (where this.getHelper() returns the database-helper which is extending from the OrmLiteSqliteOpenHelper class)
This single line needs actually round about 14 seconds to execute… Well, the “Activity” entity got about 80 fields and queryForAll returns a array with a length of 74 objects, but still – this can´t be normal, can it?
(For the Calendar fields i am using the
@DatabaseField(dataType = DataType.SERIALIZABLE)
annotation, i am not sure, if this is the right annotation for calendar fields or if it could result in performance issues…)
A
queryForAll()should not take a long time unless, as you might suspect, you have some large number of objects in your table — or a large amount of data in each object. In that case,queryForAll()has to basically dump the entire table and create a large number of objects.For larger queries it is recommended to use iterators instead of dumping the whole table:
For example, you can run through all of the objects in the query like this: