For readability reasons I would like to store a variable as a varchar such as "in", "out", "auto" instead of as a int such as "0", "1", "2". Are there any reasons why I shouldn't store it as a varchar?
The reason I ask is that I have heard that int is faster but does that apply in this scenario or will the speed difference be so small that it is negligible?
I am quite new to MYSQL so please let me know if you need any more information, I have searched for similar questions/answers but haven't found any that answer my question.
There is a simple rule of thumb: If you need to do arithmetic or indexing, use a numeric type, if not use a character type.
As rules of thumb typically depend on the size and angle of the thumb in question, here is what I mean:
+
and ()
extrasLO7SWF
will be gratefull, if you use a VARCHAR#
and *
)While it is strictly true, that an index over a VARCHAR field with numerical-only content of 11 figures is slightly slower than an INT(11), I have yet to see the real-world DB, where this makes an appreciable difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With