小编bbi*_*ras的帖子

在 MySQL 中使用 DISTINCT 时如何摆脱使用临时?

当我执行以下操作时,我得到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)

mysql performance query-performance

4
推荐指数
1
解决办法
5128
查看次数

标签 统计

mysql ×1

performance ×1

query-performance ×1