时间:2021-07-01 10:21:17 帮助过:15人阅读
先在mysql中建个表:
CREATE TABLE `t_user` ( `id` int(6) NOT NULL AUTO_INCREMENT, `name` varchar(30) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, `age` int(4) NOT NULL DEFAULT 20, `address` varchar(30) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL default ‘‘, `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `version` int(4) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) USING BTREE, UNIQUE INDEX `idx_name`(`name`) USING BTREE, INDEX `idx_age_address`(`age`, `address`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = DYNAMIC;
这个DDL创建了3个B+tree索引,我都用黄色背景标出来了。现在开始使用explain对各种查询进行分析:
1、type = ALL 是全表扫描
EXPLAIN select * from t_user; -- 全表扫描
end.
mysql5.7版本的explain解析
标签:xpl res blank cte get 使用 href size log