ORMLite is too slow on load

I have over 1500 items of this class stored in a database:

public class Task implements Parcelable{

    @DatabaseField(dataType = DataType.LONG, id = true)
    private long ActionId;
    @DatabaseField(dataType = DataType.STRING)
    private String Text;
    @DatabaseField(dataType = DataType.STRING)
    private String actionText;
    @DatabaseField(dataType = DataType.BOOLEAN)
    private boolean isUrgent;
    @DatabaseField(dataType = DataType.BOOLEAN)
    private boolean isImportant;
    @DatabaseField(dataType = DataType.BOOLEAN)
    private boolean isCompleted;
    @DatabaseField(dataType = DataType.STRING)
    private String description;
    @DatabaseField(dataType = DataType.BOOLEAN)
    private boolean isDeleted;
    @DatabaseField(foreign = true, foreignAutoRefresh = true, canBeNull = true, index = true)
    private Role role;
    @DatabaseField(foreign = true, foreignAutoRefresh = true, canBeNull = true, index = true)
    private List list;
    @DatabaseField(dataType = DataType.BOOLEAN)
    private boolean isWeekly;
    @DatabaseField(dataType = DataType.STRING)
    private String Date;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    Long ActionListId;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    private Long createdAt;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    private Long updatedAt;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    private Long deletedAt;
    @DatabaseField(dataType = DataType.BOOLEAN)
    private boolean isNew;  
    @DatabaseField(dataType = DataType.LONG_OBJ)
    private Long roleId;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    private Long WorkspaceId;
    @DatabaseField(dataType = DataType.INTEGER)
    private int order;
    @DatabaseField(dataType = DataType.STRING)
    private String WeekDate;
    @Override
    public boolean equals(Object o) {
        if(o instanceof Task) {
             Task task = (Task)o;
             if(task.getActionId() == this.getActionId())
                  return true;
             return false;
        } else return false;
    }

    @Override
    public String toString() {
        return "Name : " + Text;
    }
}

      

And this is the code for these two foreign classes:

public class Role implements Parcelable{

    @DatabaseField(dataType = DataType.LONG, id = true)
    long id;
    @DatabaseField(dataType = DataType.STRING)
    String date;
    @DatabaseField(dataType = DataType.STRING)
    String Text;
    @DatabaseField(dataType = DataType.STRING)
    String Color;
    @DatabaseField(dataType = DataType.LONG) 
    long WorkspaceId;
    @DatabaseField(dataType = DataType.INTEGER)
    int Momentum;
    @DatabaseField(dataType = DataType.BOOLEAN)
    boolean isDeleted;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    Long createdAt;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    Long editedAt;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    Long deletedAt;
    @DatabaseField(dataType = DataType.BOOLEAN)
    boolean isNew;
    @DatabaseField(dataType = DataType.INTEGER)
    private int year;
    @DatabaseField(dataType = DataType.INTEGER)
    private int month;
    @DatabaseField(dataType = DataType.INTEGER)
    private int day;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    private Long UserId;
    @DatabaseField(dataType = DataType.STRING)
    private String UserName;
    @DatabaseField(dataType = DataType.INTEGER)
    private int order;
}
public class List  {

    @DatabaseField(dataType = DataType.INTEGER, generatedId = true)
    private int id;
    @DatabaseField(dataType = DataType.LONG)
    private long ActionListId = -1;
    @DatabaseField(dataType = DataType.STRING)
    private String Name;
    @DatabaseField(dataType = DataType.LONG)
    private long WorkspaceId;
    @DatabaseField(dataType = DataType.STRING)
    private String day;
    @DatabaseField(dataType = DataType.SERIALIZABLE, canBeNull = true)
    private int[] date;
    @DatabaseField(dataType = DataType.BOOLEAN)
    private boolean parkingLot;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    private Long CreatedAt;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    private Long EditedAt;
    @DatabaseField(dataType = DataType.LONG_OBJ)
    private Long DeletedAt;
    @DatabaseField(dataType = DataType.BOOLEAN)
    private boolean IsDeleted;
    @DatabaseField(dataType = DataType.BOOLEAN)
    private boolean isNew;
    @DatabaseField(dataType = DataType.INTEGER)
    private int taskCount;
    @DatabaseField(dataType = DataType.INTEGER)
    private int Order;
}

      

Note: I've already read these posts: Wrong ORMLite performance on Android? : Ormlite DAO in android gets very slow when you are querying over several thousand results , How can I improve this way of loading objects from ORMLite on Android? I also read this: createOrUpdate ORMLite seems to be slow - what is normal speed? and the fact is that for this over 1500 elements the creation is going well, but this query is too slow:

      try {
            dao = (TaskDao) DatabaseSingleton.getDAO(Task.class);
            QueryBuilder<Task, Integer> qB = dao.queryBuilder();
            qB.where().eq("WorkspaceId", workspaceId).and().eq("isDeleted", false);
            CloseableIterator<Task> iterator = dao.iterator(qB.prepare());
             try {
                 while (iterator.hasNext()) {
                     Task item  = iterator.next();
                     ActionDto outputItem = new ActionDto(item);
                     list.add(outputItem);
                 }
             } finally {
                 iterator.close();
             }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

      

Iterator doesn't help here

One more note : I read about slow annotations and that it was fixed in Gingerbread, so I want to say which devices I am using:

  • Samsung GT-S5660 Galaxy Gio with API 2.3.3
  • GenyMotion Nexus 5 emulator 4.4.2
  • Nexus 7 with 4.1.2 API

And it runs slow for all of them, I thought it might be due to the large number of LONG_OBJECTs in my classes and the number of fields in each of them, but it actually takes so long to load over 1500 items ( It takes over 10 seconds )

And also I don't want to change the ORM because ORMLite worked fine for me except for this case

Edit: As said in the comments, I have to say that it just qB.query()

takes almoust the same amount of time as iterator

loop

+3
android ormlite


source to share


No one has answered this question yet

See similar questions:

8
ORMLite createOrUpdate seems to be slow - what is normal speed?
2
Ormlite DAO in android becomes very slow when you are querying over several thousand results
2
How can I improve this way of loading objects from ORMLite on Android?
1
Poor ORMLite performance on Android?

or similar:

3295
Why is the Android emulator so slow? How can we speed up the development of an Android emulator?
1832
Lazy loading images in ListView
1207
Strange memory issue when loading image into Bitmap object
8
Android App Development - WebView Not Working
2
Can anyone show me a simple working implementation of PagerSlidingTabStrip?
1
ORMLite foreign @DatabaseField with reverse rendering?
0
Undo / Redo not working in android Canvas
0
Ormlite config database relationship depth
-1
Activity called from service



All Articles
Loading...
X
Show
Funny
Dev
Pics