У меня есть таблица со следующей схемой:
CREATE TABLE `wordtrend` (
`oid` bigint(20) NOT NULL AUTO_INCREMENT,
`monitorId` bigint(20) DEFAULT NULL,
`nGram` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`nGramWord` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`negatives` bigint(20) DEFAULT NULL,
`neutrals` bigint(20) DEFAULT NULL,
`positives` bigint(20) DEFAULT NULL,
`total` bigint(20) DEFAULT NULL,
`trendCut` datetime DEFAULT NULL,
PRIMARY KEY (`oid`)
) ENGINE=MyISAM
AUTO_INCREMENT=358539
DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Можно ли создать индекс для эффективного выполнения следующего запроса?
SELECT nGram
, nGramWord
, SUM(total) AS sTotal
, SUM(positives)
, SUM(negatives)
, SUM(neutrals)
FROM WordTrend
WHERE monitorId = 21751021
AND trendCut >= '2011-01-01 00:00:00'
GROUP BY nGram
, nGramWord
ORDER BY sTotal DESC
Мы уже попробовали следующее:
KEY `RollupIndex` (`monitorId`,`trendCut`)
KEY `RollupIndex2` (`monitorId`,`nGram`,`trendCut`)
но мы получаем «Использование где; Использование временного; Использование сортировки файлов» в дополнительном столбце. Заранее спасибо.