Store pictures as files or in the database like MSSQL for a web app? Store pictures as files or in the database like MSSQL for a web app? asp.net asp.net

Store pictures as files or in the database like MSSQL for a web app?


Store the pictures on the file system and picture locations in the database.

Why? Because...

  1. You will be able to serve the pictures as static files.
  2. No database access or application code will be required to fetch the pictures.
  3. The images could be served from a different server to improve performance.
  4. It will reduce database bottleneck.
  5. The database ultimately stores its data on the file system.
  6. Images can be easily cached when stored on the file system.


In my recently developed projects, I stored images (and all kinds of binary documents) as image columns in database tables.

The advantage of having files stored in the database is obviously that you do not end up with unreferenced files on the harddisk if a record is deleted, since synchronization between database (= meta data) and harddisk (= file storage) is not built-in and has to be programmed manually.

Using today's technology, I suggest you store images in SQL Server 2008 FILESTREAM columns (at least that's what I am going to do with my next project), since they combine the advantage of storing data in database AND having large binaries in separate files (at least according to advertising ;) )


The adage has always been "Files in the filesystem, file metadata in the database"