Performance when storing images in database?

Soldato
Joined
12 Jun 2005
Posts
5,361
Basically I am creating an application in C#.NET with an access database (don't want the client to have to have sql server installed on their machine).

I am wondering whether it would be best to store images in a database or just store them in a folder with the filename just the ID of the record (which is fine either way).

The images will probably all be less than 100KB and most are likely to be less than 50KB. It is likely that there could be up to tens of thousands of records.

I am just wondering, from a performance point of view (reading the images & fields and displaying them on screen), which would be the better solution? (images in database or filesystem?).

I will be using the datareader object/class to read the data from the database.

Thanks.
 
Last edited:
I've always understood, it is better to reference them, rather than storing them in binary/blob format. I may be wrong but the size increase does not help the database performance.
 
Sic created a thread on this a few days ago.

In my own personal experience, if you're archiving images for retrieval as and when, then it's probably better to store them in the database.

If you're saving images to, say, be used alongside a website or view images on a daily / regular basis then the impact is gonna be huge.
 
If you are just storing the images and no data that is related to them, then file system it.

If there is a need to store associated data then use a database. Most (good) RDBMS will store the file as a blob in the database if its under a certain size but if it is over a certain size it will store it externally, with a pointer to it. IIRC.
 
Thanks for the replies guys.

I did read Sic's thread but thought that it might be aimed at people using MYSQL+PHP rather than a windows based access database+.net.

I will use a file system i think.

Cheers.
 
Our database is over 40gb thanks to storing stuff in it :(

Makes backing up a nightmare, just depends how big it would get.
 
you could argue that if you didnt have the images in your database then it would still be ~40GB for backing up purposes...

granted you could backup all data excluding images a lot quicker.
 
The data used is not likely to be backed up tbh...all the data and images could easily be recreated by clicking one button, although it may take about an hour to recreate the whole database + images, it is unlikely that any user intervention is needed.
 
If you ever decide to use a DB and want to use SQL Server 2008 when it is released there is a new filestream data type which would come in handy for storing images instead of the normal blobs.
 
Back
Top Bottom