But one day longer is super lowslow:
That's weirdThe EXPLAIN
of the may 23rd one (the fast one), also shows that now it does use Using where; Using index
.... That seems to be a deciding factor.
Tables:
CREATE TABLE `logs` (
`idLog` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`idSite` int(10) unsigned NOT NULL,
`secondsToNextLog` int(11) DEFAULT NULL
`gwRestarted` tinyint(4) NOT NULL
`timestamp` int(10) unsigned DEFAULT NULL
PRIMARY KEY (`idLog`),
KEY `idSite` (`idSite`,`timestamp`),
CONSTRAINT `logs_ibfk_1` FOREIGN KEY (`idSite`) REFERENCES `sites` (`idSite`)
) ENGINE=InnoDB AUTO_INCREMENT=380946254 DEFAULT CHARSET=latin1
CREATE TABLE `logData` (
`idLog` bigint(20) unsigned NOT NULL,
`instance` smallint(5) unsigned NOT NULL
`idDataAttribute` smallint(5) unsigned NOT NULL,
`valueFloat` float DEFAULT NULL,
`valueString` varchar(255) DEFAULT NULL,
`valueEnum` smallint(6) DEFAULT NULL,
PRIMARY KEY (`idLog`,`instance`,`idDataAttribute`),
KEY `logdata_ibfk_4` (`idDataAttribute`),
CONSTRAINT `logData_ibfk_3` FOREIGN KEY (`idLog`) REFERENCES `logs` (`idLog`) ON DELETE CASCADE,
CONSTRAINT `logData_ibfk_4` FOREIGN KEY (`idDataAttribute`) REFERENCES `dataAttributes` (`idDataAttribute`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CREATE TABLE `dataAttributes` (
`idDataAttribute` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`code` varchar(25) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`idDeviceType` int(10) unsigned NOT NULL,
`description` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`dataType` enum('float','string','enum') COLLATE utf8_unicode_ci NOT NULL,
`sortOrder` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`exportType` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
`formatValueOnly` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`formatWithUnit` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`idDataAttribute`),
UNIQUE KEY `code_UNIQUE` (`code`),
KEY `idDeviceType` (`idDeviceType`,`idDataAttribute`),
CONSTRAINT `dataAttributes_ibfk_1` FOREIGN KEY (`idDeviceType`) REFERENCES `deviceTypes` (`idDeviceType`)
) ENGINE=InnoDB AUTO_INCREMENT=251 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci