Does using a smallint datatype in a mysql table over a regular int actually improve memory usage? Wouldn't the hardware just allocate a full 64 bit word size for all data anyway? If it doesn't allocate a full word, then wouldn't we see a performance decrease from having to parse out multiple smallints or tinyints from a 64 bit word allocated in memory?
Basically, is there any design/memory/performance benefit to using the following table over the one after it, assuming we know the range of the values stored in the Status
column will never exceed the max/min range of smallint? Any insight would be appreciated:
create table `TestTableWithSmallInt` (
`ID` bigint(20) NOT NULL AUTO_INCREMENT,
`Status` smallint(11) DEFAULT 0,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table `TestTableWithInt` (
`ID` bigint(20) NOT NULL AUTO_INCREMENT,
`Status` int(11) DEFAULT 0,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;