Have a problem with querying data via Ormlite DAO, when there are few thousand results.
Code:
List<Point> pl = db.getPointsDAO().queryBuilder().where().
eq("route_id", croute).query();
When I want to get a large list of points List<Point> pl for current Route croute I have to wait like 40 sec for 40.000 points.
where Point.class is:
@DatabaseTable(tableName = "points")
public class Point extends BaseEntity {
@DatabaseField(generatedId = true)
private Integer point_id;
@DatabaseField(canBeNull = false)
...
@DatabaseField(canBeNull = false)
private Double dose;
@DatabaseField(dataType=DataType.DATE_STRING, format="yyyy-MM-dd HH:mm:ss")
public Date date;
@DatabaseField(canBeNull=true,foreign=true)
private Route route;
public Point() {
super();
};
... ...
}
and Route.class is:
@DatabaseTable(tableName = "routes")
public class Route extends BaseEntity {
@DatabaseField(generatedId = true)
private Integer route_id;
@DatabaseField(canBeNull = true)
private String name;
@ForeignCollectionField(eager = false)
ForeignCollection<Point> points;
public Route() {
super();
}
... ...
}
Some ideas what I’m doing wrong?
Thanks,
Toni
Couple of things to try @toni.
Dateas aDATE_LONGinstead of a string which will save 40k string/date conversions.intanddoubleprimitives to lower your GC for each of your objects although I doubt it will make much of a difference.adb logcatutility to see if you can see the GC times to see if you are just thrashing the collector. Anything that you can do to lower your memory usage will help then. Look for lines like:index = trueon the foreignroutefield.