Mysql Explain??????????????
?????WhyWin ???????[ 2016/9/13 10:50:41 ] ????????????? MySQL
????explain?????mysql????????????????select????????????????????????????????д??????????????
????1???????????
??????????sql??????£?
/*
Navicat MySQL Data Transfer
Source Server : localhost-newpassword
Source Server Version : 50550
Source Host : localhost
Source Database : testExplain
Target Server Version : 50550
File Encoding : utf-8
Date: 08/05/2016 18:06:12 PM
*/
SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for `user`
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL??
`name` varchar(30) NOT NULL??
`age` int(11) NOT NULL??
`sex` tinyint(4) NOT NULL??
`isDeleted` tinyint(4) NOT NULL??
PRIMARY KEY (`id`)??
UNIQUE KEY `id_unidx` (`id`) USING BTREE??
UNIQUE KEY `name_unidx` (`name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of `user`
-- ----------------------------
BEGIN;
INSERT INTO `user` VALUES ('1'?? 'wwwwe'?? '11'?? '1'?? '0')?? ('2'?? '222'?? '22'?? '1'?? '0')?? ('3'?? '2222'?? '10'?? '0'?? '0');
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;
????2??explain??÷???
??????÷???????select????????explain ????????磺
????explain select * from user where id = 1
?????????
????+----+-------------+-------+-------+------------------+---------+---------+-------+------+-------+
????| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
????+----+-------------+-------+-------+------------------+---------+---------+-------+------+-------+
????| 1 | SIMPLE | user | const | PRIMARY??id_unidx | PRIMARY | 4 | const | 1 | |
????+----+-------------+-------+-------+------------------+---------+---------+-------+------+-------+
????3??explain????????????
????id??select???????????select??????к????????????????????sql?????е????
????select_type????????漸?????
????simple ?????????select?????union??????
????primary ?????select????????????????У??????select?????primary
????union union???????????????????????.
????dependent union UNION?е???????????SELECT???????????????
????union result UNION????
????table:?????????????
????type:????????????????????????????????????const??eq_reg??ref??range??indexhe??all
????const??????????????У?const??????primary key ????unique?????????????????????????????????????primary key ????unique
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11