Ormlite DAO in android getting really slow when querying more than few thousand results

被刻印的时光 ゝ 提交于 2019-11-29 08:43:14

Couple of things to try @toni.

  1. I'd consider storing your Date as a DATE_LONG instead of a string which will save 40k string/date conversions.
  2. @Selvin is right that if there is some way for you can iterate through the database, this may lower your memory requirements and speed things up. See dao.iterator() in ORMLite.
  3. I'd use int and double primitives to lower your GC for each of your objects although I doubt it will make much of a difference.
  4. Try loading in 1000 points, then 10000, then 20000 to see if there is a drop off in performance at some point. That will tell you that you are hitting up against memory limits.
  5. Use the adb logcat utility 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:
    GC_EXPLICIT freed 4140 objects / 216560 bytes in 114ms
  6. Although I doubt it is the issue, could you be missing an index? Try adding a index = true on the foreign route field.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!