BLOB vs. VARCHAR for storing arrays in a MySQL table

前端 未结 4 2187
终归单人心
终归单人心 2020-12-09 10:38

I\'ve got a design decision to make and am looking for some best practice advice. I have a java program which needs to store a large number (few hundred a day) of floating

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 11:14

    If you just want to store the data as a binary dump of the Java array then, by all means, use a BLOB. Your friend may well be advising against this since you may want some non-Java program to use the information at some later date so binary dumps are probably a pain to interpret.

    With serialization to a VARCHAR, you know the data format and can easily read it with any application.

    Of course, if there's even the slightest chance that you'll want to manipulate or report on the individual floats, they should be stored in a database-friendly format. In other words, not a binary dump, not serialized, not a CSV column.

    Store them as Codd intended, in third normal form.

    By the way, a few hundred 300-element floating point arrays each day is not a big database. Take it from someone who works on the mainframe with DB2, most DBMS' will easily handle that sort of volume. We collect tens of millions of rows every day into our application and it doesn't even break into a sweat.

提交回复
热议问题