我有一个像这样的简单JOIN
:
select a.id
from tablex a, tabley b
where a.id_fk=b.id
order by a.id
limit 5;
如果表是MyISAM,一切都还可以。结果"解释"是"Using index"
。
如果具有相同数据的相同表是InnoDB,则"解释"是"Using index; Using temporary; Using filesort"
。
InnoDB配置有什么问题?我应该修改哪个变量来使用索引?
这是数据库:
CREATE TABLE `table2x` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_fk` int(11) NOT NULL DEFAULT '0',
`title` varchar(255) NOT NULL DEFAULT '',
`title2` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `id_licitatie_idx` (`id_fk`)
) ENGINE=MyISAM AUTO_INCREMENT=116902 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `table2y` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=49116 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `tablex` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_fk` int(11) NOT NULL DEFAULT '0',
`title` varchar(255) NOT NULL DEFAULT '',
`title2` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `id_licitatie_idx` (`id_fk`)
) ENGINE=InnoDB AUTO_INCREMENT=116902 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `tabley` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=49116 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;