Lets assume I want to save the count of datagrid rows which can be max. 24 because each row is 1 hour.
To save the row index in the database a tinyint field would be totally enough. But back in my mind I remember slightly that databases are optimized for integers?!
So is it worth to use tinyint?
If you include 2 or 3, you have to use tinyint (at the very smallest scale). "For example, it's better to use tinyint when you know that the only data you will store is a 1, 0 or null (with a very small chance of expanding that to a 2 or 3 later)." I'd use an ENUM for such a thing.
The TINYINT data type is an integer value from 0 to 255. TINYINT is the smallest integer data type and only uses 1 byte of storage. An example usage of TINYINT is a person's age since no person reaches the age of 255.
With a narrower table, the database will fit more records in a single IO page, and will therefore require fewer hard disk reads.
The rule of thumb is to always use the data type that will require the least storage size.
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