Better way to store files in Database or in filesystem..?


If you are working with files in asp.net it is better to Store the files on the file system and filepath in the database. In many situations, databases are stored on fast (read: expensive storage, 15k RPM or SSD drives) storage. Images or other files, typically can be stored on slower (read: cheaper, larger drives, 7.2k RPM drives) storage.

Because…

  1. You can access files faster
  2. easier to configure security settings
  3. No size limitation
  4. You will be able to serve the pictures as static files.
  5. No database access or application code will be required to fetch the pictures.
  6. The images could be served from a different server to improve performance.
  7. you don’t get into any trouble, if you have to migrate your back end.
  8. It will reduce database bottleneck.
  9. The database ultimately stores its data on the file system.
  10. Images can be easily cached when stored on the file system.

still if you want to store files in DataBase only, better to use FileStream field type which can provide the best of both worlds.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s