Save image in database: Recently we got one requirement to save image ( Maximum size of image in our scenario was 25 MB ) and we had to take decision what is best approach to save image either in database or on disc. We did lots of research including our own POC and ran query against database and disc lastly we found below:
- Saving image in database is good when your image size is small
- If image size is big then it’s good to create meta data of image save its reference into database and real image save on disc. This is way faster than saving image in database.
- Saving image on disc is static content and multiple database can use it.
- Save image in disc take no extra burden compare to database where you have do tuning to retrieve image faster.
- You can have a single database and several servers serving static content. It will be much faster to have several databases doing that work.Flickr is an example and works this way.
Finally we decided to save file on disc and keep meta data reference into database.