当我执行以下操作时,我得到Using where; Using index; Using temporary. 我该如何摆脱Using temporary?
http://sqlfiddle.com/#!8/f61a2/3/0
CREATE TABLE `test` (
`a` varchar(45) NOT NULL,
`b` varchar(45) NOT NULL,
`date` date NOT NULL,
PRIMARY KEY (`a`,`b`),
KEY `index1` (`b`,`date`),
KEY `index2` (`b`,`date`,`a`)
) ENGINE=InnoDB;
INSERT INTO test (a, b, date) VALUES ('a1', 'b1', now());
INSERT INTO test (a, b, date) VALUES ('a1', 'b2', now());
INSERT INTO test (a, b, date) VALUES ('a2', 'b1', now());
INSERT INTO test (a, b, date) VALUES ('a2', 'b2', now()); …Run Code Online (Sandbox Code Playgroud)