Answer the question
In order to leave comments, you need to log in
About choosing the right length for a BIGINT field in MySQL
It is known that for MySQL, in general, there is no linear dependence of the disk space spent on storing data on the character length of this data. A classic example of this feature is the behavior of VARCHAR fields: the string 'abcd' takes up 5 bytes when placed in a VARCHAR field, and 4 bytes when stored in a CHAR(4) field. This phenomenon is described in detail in the manual at dev.mysql.com/doc/refman/5.1/en/char.html
However, the cost of storing the row itself is not limited - there are also indexes, there are external links, and probably something else that stays out of the client's field of vision. Something that responds to the correct choice of field type and length by varying amounts of disk space being consumed.
My question is this:
(11), and no more than 8 bytes for INT(20 ) .
KEY from other tables with cascading CONSTRAINT on UPDATE.
I'd love to hear your thoughts on the correct BIGINT length selection algorithm, the correctness of my thoughts, and the MySQL mechanisms that deal with client-declared field lengths.
In the meantime, having learned from the bitter experience of a sudden stop in production due to the fact that the field ran into INT (11), I can wish all administrators to check the values of auto-increment counters in their databases more often, so as not to repeat my fate, having received an accident with a serious downtime on empty place.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question