Skip navigation

Storing BLOBs in the Database or the File System?

A point of contention usually arises with the topic of relational databases and binary large object (BLOB) data: Is it better to integrate BLOBs within the database or store them in the file system? Each method has its advantages and disadvantages.

Related: Don't Be Afraid of BLOBs and CLOBs

Storing BLOB data such as images, audio files, and executable files in the database with typical text and numeric data lets you keep all related information for a given database entity together. And this approach enables easy search and retrieval of the BLOB data; you simply query its related text information. However, storing BLOB data can dramatically increase the size of your databases.

The common alternative to this technique is storing binary files outside the database, then including as data in the database a file path or URL to the object. This separate storage method has a couple of advantages over integrating BLOB data within the database. It’s somewhat faster because reading data from the file system involves a bit less overhead than reading data from a database. And without the BLOBs, your databases tend to be smaller. However, you must manually create and maintain a link between the database and external file system files, which have the potential to get out of sync. In addition, you usually need a unique naming or storage scheme for the OS files to clearly identify the potentially hundreds or even thousands of BLOB files. Storing BLOB data within the database eliminates these problems by letting you store BLOB data along with its related relational data.

TAGS: SQL
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish