1

I am asked to store small files in a mysql database. They are limited to 150kb.

What data type is the most efficient to use? BINARY(150000), VARBINARY(150000) or MEDIUMBLOB ?

Jeremie
  • 1,267
  • 12
  • 33
  • Thank you for your link but I do not see how it is related? My question is about performances and how to store small files in a database. That question is about setting the database to allow only specific data on insertion like ENUM would do. – Jeremie Feb 04 '14 at 13:21
  • The duplicate link points to the wrong SO thread. I was linking to this one. http://stackoverflow.com/questions/8476968/varbinary-vs-blob-in-mysql – Samuel Feb 04 '14 at 13:24
  • it's more related to this one but I did not find any answer though: http://stackoverflow.com/questions/211895/storing-documents-as-blobs-in-a-database-any-disadvantages – Jeremie Feb 04 '14 at 13:30

2 Answers2

0

Have you considered storing your files in a file system and in the database maybe storing only metadata such as relative path ? I think thats the right way

ziker
  • 160
  • 3
  • 16
  • 1
    I would have done the same, but a senior developer asked me to. As I read here, it is not mandatory to use a file system, it depends on the size of the stored files: "As expected from the common wisdom, objects smaller than 256K are best stored in a database while objects larger than 1M are best stored in the filesystem." http://research.microsoft.com/apps/pubs/default.aspx?id=64525 – Jeremie Feb 04 '14 at 13:29
0

Ok I got my answer so I share it here: since we finally wanted to use the column to store short texts (value of the message can be an embedded file or some text), I used mediumblob that consists of text. And any way on the web, I found references to blob rather than to binary types.

FYI the file is encoded in binary Base64 format.

Jeremie
  • 1,267
  • 12
  • 33