Store images to SQL database vs file system
Posted on 2009-04-13
MS SQL 2005/2008
ASP.NET (C#) 2.0/3.x
We are developing a classifieds type website where a user can upload 1 to 5 images. Each image will be less than 50K in size, and will have thumbnails created for each image uploaded. Some of the benifits of using SQL database to store images, deleting a user record, the users images can be deleted at the same time. This helps with backup issues and orphan images are addressed also.
Does it make sense performance-wise to go in this direction rather than storing the images in the file system?
In this type of site, what would be the most effecient way to retrieve multiple images at once to show on a page. An example would be where a website user clicks on an ad, and the page would serve up the ad text and any thumbnail images related to that ad ID, and each would be clickable to view the larger image. I have done this storing images in the file system, but I'm a little fuzzy on retrieving multiple thumbnail images and also links to the larger images from a SQL server.
Also, should thumbnails be created and stored as seperate images in the database or generated on the fly when the page is requested?