我在MySQL数据库中有这两个表:
CREATE TABLE IF NOT EXISTS `articles` (
`id` bigint(20) NOT NULL,
`url` varchar(255) collate utf8_bin NOT NULL,
`img` varchar(255) collate utf8_bin NOT NULL,
`name` varchar(255) character set utf8 collate utf8_unicode_ci NOT NULL,
`url_key` varchar(255) character set utf8 collate utf8_unicode_ci NOT NULL,
`type_code` varchar(255) character set utf8 collate utf8_unicode_ci NOT NULL,
`likes_count` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `type` (`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `articles_types` (
`id` int(11) NOT NULL auto_increment,
`code` varchar(255) character set utf8 collate utf8_unicode_ci NOT NULL,
`url_key` varchar(255) character set utf8 collate utf8_unicode_ci NOT NULL,
`name` varchar(255) character set utf8 collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`code`),
KEY `type` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
我正在尝试运行此查询:
SELECT a.* FROM `articles` a INNER JOIN articles_types at ON at.`code`=a.type ORDER BY p.likes_count DESC LIMIT 1
返回1行, 1秒。
表格文章包含大约超过70k行,articles_types只有大约70行。
是否有机会优化该表的结构(可能是引擎?),或者优化查询本身以使其更快?