Monday 8 June 2015

Is It Okay To Store Images In A SQL Server Database?

There are advantages and disadvantages to storing pictures/images into an SS Database versus storing the physical file in a folder.

In my personal experience, I can point out  a few points that saving them into the database can be better:
  • It protects the images from prying eyes or from malicious viruses that encrypt files.
  • If the machine where the SQL Server is hosted from has good specs, then there's a good chance that downloading and uploading pictures to the database is going to be fast. 
  • You are free to add more search parameters compared to doing searches in folders locally or over the network. You can add more tags to an image instead of relying only to its filename. For example, I can search for a picture using a unique code identifier (barcode) or do a wildcard search using its description.
Some disadvantages could be:
  • If you're storing large images in a table particularly high-resolution pictures with over 2MB in size, you may find that running a query on that table may slow down in time as you insert more pictures. The solution to this is to downsize the image before inserting them to a varbinary(max) field. Instead of inserting a 4MB picture, reducing the image's size down to let's say, 80KB before uploading it can help a lot. (I created my own Image/Picture Downsizing program using VFP and GDI+ to convert high-res picture to a descent low-res picture to help the company that I currently work with.)

Transfer and Downgrade is a module for Tangosoft I created to reduce the size of the images stored in our database.
  • Takes up space in the server. This is inevitable if you decide to store images into a SQL Server Database. But again, reducing the size of the image can help with saving space. I have stored tens of thousands of pictures in a SS database and the benefits that I gain have overshadowed those of the disadvantages.
Related Posts Plugin for WordPress, Blogger...