Kyle
Kyle

Reputation: 33691

Storing files in SQL server vs something like Amazon S3

Whats the advantage/disadvantage between storing files as a byte array in a SQL table and using something like Amazon S3 to store them? Whats the advantage of S3 that makes it so I should use that instead of SQL?

Upvotes: 5

Views: 1938

Answers (1)

Aaron Bertrand
Aaron Bertrand

Reputation: 280252

Pros for storing files in the database:

  • transactional consistency
  • security (assuming you need it and that your database isn't wide open anyway)

Cons for storing files in the database:

  • much larger database files + backups (which can be costly if you are hosting on someone else's storage)
  • much more difficult to debug (you can't say "SELECT doc FROM table" in Management Studio and have Word pop up)
  • more difficult to present the documents to users (and allow them to upload) - instead of just presenting a link to a file on the file system, you must build an app that takes the file and stores it in the database, and pulls the file from the database to present it to the user.
  • typically, database file storage and I/O are charged at a much higher premium that flat file storage

Upvotes: 5

Related Questions