SQLITE Blob OR image file system

I am creating an application based on a single table with a column with text. Sometimes the adjacent column will have an image. Is it better to store this image as a BLOB in SQLITE, or should I store them in the file system and reference them from my programs. Thanks!

+6
filesystems sqlite iphone
source share
5 answers

Ultimately, files will cause less problems. You really don't want to serve many files from your database server, especially when you scale

+3
source share

Assuming that the images you are going to use are not very large, and their number will not exceed, I would go with a database.

I currently use the Sqlite database on several Windows Mobile and WinCE devices with over 10,000 small images stored as blocks, and it works fine.

I saw software similar to ours running on the same hardware using file-based image loading, and it was much slower. Of course, it was on WinCE and various software, so this is not the best test.

I find it much easier to work with one database than with multiple image files.

+3
source share

EDIT:

I did not understand what you specifically intended for the iPhone. In this case, I would use the DB just for simplicity to have all the content in one place. You do not have to worry about scalability, because it does not look like your iphone will be used as a server or something else.

Original answer:

I have no references to this, but I remember how several studies said that the "cutoff" is 1 MB for blob efficiency. But it can move up to 10 MB with a fairly fast disk array. It depends entirely on the system.

So, basically, taking into account the efficiency cut-off, any data smaller than this is better served by the database, whatever, simply indexed in the database and left in the file cache.

+2
source share

I like to save images to the file system, because UIImage can cache image files and automatically unload them from memory when necessary. Just be careful not to modify or delete the image file loaded in UIImage, or you will get crashes or other strange errors.

+2
source share

It really depends on your application. Having the images stored in the database will simplify your life, as you can easily get them at one point, instead of having them in separate files that might be missing. On the other hand, many images that are quite large may be too large for the SQLITE database. In your situation, I would just refer to them in the database.

+1
source share

All Articles