4

In my website project, I need to upload the end-user's pdf files and save them. every 3 months I guess to receive around 2000 pdf files with 2MB size for each pdf. What is the best solution? saving the files in hard-disk (in a folder) and save file-address in the DB < or > saving the files directly in a blob-field in the db(MySQL)

RGDS

Nav
  • 4,450
  • 10
  • 53
  • 84

2 Answers2

9

Saving large amounts of binary data as BLOBs is not a good idea because the benefits over using a regular file system are minimal and the load on the DBMS is increased. Storing a file on the disk and file's name in the DB is a better idea.

One thing to remember is to avoid putting all files into single directory (doing this will slow down the file system when the files are accessed). Put them into subdirectories and use first couple of characters of the file name as the name of the subdirectory.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
  • 1
    +1 I've previously built an app that would produce 1000s of PDFs per day with a requirement for the produced PDF to be saved and I implimented it in this way. In addition saving to the OS rather than as a BLOB means the PDF can be reviewed without having to access via the db/moved to another drive without too much effort – CResults Nov 20 '10 at 20:26
1

I think a good rule thumb is to decide which resource is cheaper for you, disk-space or memory. If it's the later than go for db-based solution, otherwise use the file system.

Having said that, the idea of storing 2MB pdf files storing as BLOBs in MySQL doesn't sound so efficient.

rubayeet
  • 9,269
  • 8
  • 46
  • 55