1.table des
innodb_test
CREATE TABLE `innodb_test` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`city` varchar(255) DEFAULT NULL,
`status` mediumint(9) DEFAULT NULL,
`date` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `name_city_satus` (`name`,`city`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1;
myisam_test** is just the same as innodb_test but with MyISAM engine.
2.I run the fllowing sql getting 57 rows:
1):
SELECT SQL_NO_CACHE * FROM innodb_test WHERE `name` LIKE 'H%' AND city LIKE 'O%' LIMIT 0, 10000;
2):
SELECT SQL_NO_CACHE * FROM myisam_test WHERE `name` LIKE 'H%' AND city LIKE 'O%' LIMIT 0, 10000;
By show profilings, the first sql takes 0.029s, while the other takes 0.0069.
Why they have so big difference?
Try add Fixed row format to your table .
44% improvement in speed for Fixed row format over Dynamic.
The disadvantage to Fixed row formats is the space required to store columns. Changing to a Fixed row format will pad any variable length columns with spaces. However, any time your trade-off for performance comes at a cost of disk space, performance wins.
ALTER TABLE `innodb_test` ROW_FORMAT = FIXED
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.