hky

Storing Images - File system or SQL?

Pro File System

Saturday, November 15 2003 @ 12:43 PM IST
Contributed by: berber

There are two main ways to store images :

The obvious and easy way is to simply upload them to your WebServer and store them in some appropriate directory structure. In this method, only the file name needs to be saved in the database along with any other info you may need like image size, width, height etc…
A 2nd option is to load the actual images to a database along with the info stated above.

It is my opinion that the 1st option is better for several reasons :

Storing the image in the database causes, a very large database, and a separate call to load the image.
Having the actual images in a directory allows for easy access to find and replace any image quickly and easily.
Development time is shorter because you don’t need to develop an interface that stores images in the database, as well as one to retrieve the images from the database. This means that you actually need to run a PHP script when you need an image.
In most cases, the file system will deal with retrieving the images and passing them to the web server much better than the database and this will also take some of the load off the database.
On the other hand,

If you are dealing with a big number of images (tens of thousands or hundreds of thousands) you need to keep a very specific directory structure with sub directories to avoid file system performance limitations. In this case, storing the images in a database may result in better performance.
Managing images in a database is easier than managing endless files in an endless number of directories.

Pro SQL

Authored by: edk on Tuesday, April 06 2004 @ 08:49 PM IST

I have to disagree, I have one project with 16,000 images (http://photos.edebris.com/catalog/ 1.3GB). My next project will have over 5,000,000 images http://www.phppo.cdc.gov/cyto/CytoView_Demo.asp currently 80GB) . I choose to store the images in a database so that all the images are packed together on the drive, unlike a file system that would store the images in blocks.
Don’t confuse recompression time with retrieval time. If the requested image quality/size is not available, it is created, and stored in the database.

Comments

Proudly published with Hexo