I would like to store some protobuf objects in a MySQL database. The objects are created in a Java application. The object is accompanied with a textual type identifier and a timestamp.
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | mediumint(9) | NO | PRI | NULL | auto_increment |
| type | varchar(30) | NO | MUL | NULL | |
| timestamp | date | NO | MUL | NULL | |
| pixel_data | ? | NO | MUL | NULL | |
+------------+--------------+------+-----+---------+----------------+
What should be the datatype of pixel_data
?
My best guesses are either BLOB
or TEXT
.
- What's the difference between
TEXT
andBLOB
? Which one is better for Java serialization ofprotobuf
objects? Since Java serializes using byte streams, I assume that BLOB is better, but I didn't find any reference for that. - Assuming that I can only estimate object sizes, which quantifier should I choose (
TINY
,MEDIUM
orLONG
)? How much space is wasted for the larger sizes?