开发者

When should we store images in database?

开发者 https://www.devze.com 2023-01-25 12:24 出处:网络
I have a table of productList in which i have 4 column, now i have to store image for each row so i have two option for this..

I have a table of productList in which i have 4 column, now i have to store image for each row so i have two option for this..

  • Store image in data base.
  • Save images in a folder and store only path on table.

So my question is which one is better in this sit开发者_如何学运维uation and why ?


Microsoft Research published quite an extensive paper on the subject, called To Blob Or Not To Blob.

Their synopsis is:

Application designers often face the question of whether to store large objects in a filesystem or in a database. Often this decision is made for application design simplicity. Sometimes, performance measurements are also used. This paper looks at the question of fragmentation – one of the operational issues that can affect the performance and/or manageability of the system as deployed long term. As expected from the common wisdom, objects smaller than 256K are best stored in a database while objects larger than 1M are best stored in the filesystem. Between 256K and 1M, the read:write ratio and rate of object overwrite or replacement are important factors. We used the notion of “storage age” or number of object overwrites as way of normalizing wall clock time. Storage age allows our results or similar such results to be applied across a number of read:write ratios and object replacement rates.


It depends - You can store images in DB if you know that they wont increase in size very often. This has its advantage when you are deploying your systems or migrating to new servers. you dont have to worry about copying images seperately.

If the no. of rows increase very frequently on that system, and the images get bulkier, then its good to store on the file system and have a path stored in database for later retrieval. This also will keep you on toes when migrating your servers where you have to take care of copying the images from filepath seperately.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号