Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android sqlite / BLOB perfomance issue

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 suspect that the problem is with the images I store in a BLOB field.

The application creates Cards that have a field cardBitmap that gets populated with a bitmap upon creation.

Can anyone tell me from their experience, what solution is more performant:

  1. cardBitmap holds a reference (path) to a file on SDcard that will be drawn upon creation. Only path is stored in DB.
  2. cardBitmap holds an object (BitmapFactory.decodeStream(imageStream,null,null)), where imageStream is read as a ByteArrayInputStream from the corresponding database field.

Any suggestions would be helpful. Thanks!

like image 378
Sgali Avatar asked Nov 30 '22 07:11

Sgali


1 Answers

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.

like image 95
Thibault D. Avatar answered Dec 04 '22 14:12

Thibault D.