I have a MySQL table with more than a billion rows hosted on Google Cloud SQL.
>> SHOW CREATE TABLE depth
CREATE TABLE `depth` (
`date` date DEFAULT NULL,
`receive_time` datetime(3) DEFAULT NULL,
`instrument_token` bigint(20) unsigned DEFAULT NULL,
`level` tinyint(3) unsigned DEFAULT NULL,
`bid_count` smallint(5) unsigned DEFAULT NULL,
`bid_size` bigint(20) unsigned DEFAULT NULL,
`bid_price` float DEFAULT NULL,
`ask_price` float DEFAULT NULL,
`ask_size` bigint(20) unsigned DEFAULT NULL,
`ask_count` smallint(5) unsigned DEFAULT NULL,
KEY `date_time_sym` (`date`,`receive_time`,`instrument_token`),
KEY `date_sym_time` (`date`,`instrument_token`,`receive_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
To get the data and index size, I run the query
SHOW TABLE STATUS from mktdata where Name = "depth";
Here I get a table output with one row, with value of a few important fields as:
Name: depth
Engine:InnoDB
Version:10
Row_format:Dynamic
Rows: 1,72,08,21,447
Avg_row_length: 78
Index_length: 1,83,90,03,07,456
Data_length: 1,35,24,53,32,480
Question: Why is Index_length
larger than Data_length
? You can see my indexes above, why do they need so much space to be stored? I don't know much about how indexes are created and stored so please explain from the basics.