Yea or Nay?

So I'm using an app that stores images heavily in the DB. What's your outlook on this? I'm more of a type to store the location in the filesystem, than store it directly in the DB.

What do you think are the pros/cons?


I'm in charge of some applications that manage many TB of images. We've found that storing file paths in the database to be best.

There are a couple of issues:

  • database storage is usually more expensive than file system storage
  • you can super-accelerate file system access with standard off the shelf products
  • for example, many web servers use the operating system's sendfile() system call to asynchronously send a file directly from the file system to the network interface. Images stored in a database don't benefit from this optimization.
  • things like web servers, etc, need no special coding or processing to access images in the file system
  • databases win out where transactional integrity between the image and metadata are important.
  • it is more complex to manage integrity between db metadata and file system data
  • it is difficult (within the context of a web application) to guarantee data has been flushed to disk on the filesystem

  • As with most issues, it's not as simple as it sounds. There are cases where it would make sense to store the images in the database.

  • You are storing images that are changing dynamically, say invoices and you wanted to get an invoice as it was on 1 Jan 2007?
  • The government wants you to maintain 6 years of history
  • Images stored in the database do not require a different backup strategy. Images stored on filesystem do
  • It is easier to control access to the images if they are in a database. Idle admins can access any folder on disk. It takes a really determined admin to go snooping in a database to extract the images
  • On the other hand there are problems associated

  • Require additional code to extract and stream the images
  • Latency may be slower than direct file access
  • Heavier load on the database server

  • File store. Facebook engineers had a great talk about it. One take away was to know the practical limit of files in a directory.

    Needle in a Haystack: Efficient Storage of Billions of Photos

    链接地址: http://www.djcxy.com/p/67500.html

    上一篇: 在Android ICS的内存中读取图像无法正常工作

    下一篇: 是或否?