Im a bit confused and need some input.
I have created 2 tables here
CREATE TABLE `table1` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Value` varchar(45) DEFAULT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `table2` (
`Value` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
When i look at the size of the file in the temp folder. They are both 96 kb
I simply inserted 10240 items into both columns.
SELECT count(*) FROM temp.table1;
SELECT count(*) FROM temp.table2;
Gives
10240
10240
If i now look into the size of the tables, this is what i get.
I discovered this when i changed one of my innodb tables and added a AUTO_INCREMENT PRIMARY KEY
, and the size was over 3 GB less.
I am under the impression that innodb has a internal PRIMARY KEY
in case one isnt defined? But how can it be that the table with 1 column less, actually takes up more space? There is no index in the table2
(except the internal PRIMARY KEY
) , and a PRIMARY KEY
defined on table1
Does this mean that the internal innodb PK is using BIGINT
for instance?
EDIT
After changing the PK to BIGINT , the sizes of the files are now the same. Simple as that.
This does however raise another question. Is the LIMIT of MySQL
rows the maximum of BIGINT
(which is big yes, but there is in fact a limit then right)?