Android sqlite / BLOB perfomance issue

后端 未结 3 2018
暗喜
暗喜 2020-12-29 16:15

Ever since I moved my data from ArrayList to a sqlite database on Android, I have a serious performance drop. There are no cursors left open that could cause that, so I susp

相关标签:
3条回答
  • 2020-12-29 16:59

    I have not enough reputation to do comments as well. I'm adding this answer to help anyone who still looking for some suggestion. After several years hardware improvement, performance of that two solutions have little difference. I've tried several times in my Nexus 6p writing an about 2 MB image binary to SQLite only takes 50 ms in average. Even though external storage will perform better, current performance can meet my expectation. Write to SQLite do not need WRITE_EXTERNAL_STORAGE permission which may be revoke if permission granted from other apps. In this case, SQLite can be a good choice.

    0 讨论(0)
  • 2020-12-29 17:00

    I don't have the reputation yet to comment an answer, so I'll add my 2cts as an answer instead, please forgive me.

    I was looking for an answer to a similar question and I don't think the current answer is satisfying because if you ask SQLite.org they'll tell you that it depends on the blob size and on the page size.

    They have done a benchmark - not on android though - that shows that storing blobs in SQLite is faster for small blobs (up to 20kB) than storing on separate files. For blobs greater than 100kB though, the performance drop is big and it's better storing the blobs in separate files as you ( user370605 ) recommend. See http://www.sqlite.org/intern-v-extern-blob.html

    I'll consider the question not answered regarding Android.

    0 讨论(0)
  • 2020-12-29 17:01

    Your first solution is better one, Use a file from sdcard and store the reference path in your sqlite database, This gives you faster performance and also your database is remain light weight.

    0 讨论(0)
提交回复
热议问题