0

It's recommended to store file into a directory on web server. Why not use a BLOB data type for a column where store files? There are security and consistency advantages and it's easier to manage files doing that. What are the cons?

Ricla
  • 105
  • 1
  • 9

2 Answers2

1

The main reson is that space and performance hit can be quite big and database storage is usually more expensive than file system storage. Here is an excellent resource discussing it.
Also this SO thread has everything there is to this debate

Community
  • 1
  • 1
Tony Vincent
  • 13,354
  • 7
  • 49
  • 68
0

It's recommended to store file into a directory on web server

Not always - besides the fact this simply does not apply in cases where there is no web-server (e.g. internal native applications).

Why not use a BLOB data type for a column where store files?

It depends on your application's scale and use-cases. What do these blobs represent? Will they be updated regularly? Is there any opportunity for caching or a distribution system?

There are security and consistency advantages and it's easier to manage files doing that. What are the cons?

Performance is the main reason. Reading from a database is generally always slower than reading from disk because of overheads introduced by the DBMS. Writing is also considerably more expensive because of the internal storage layout inside the database system.

Dai
  • 141,631
  • 28
  • 261
  • 374