restructure indexes on the various Events tables. Use two separate indexes for MonitorId and StartTime because we access these tables using one or the other, but rarely both

This commit is contained in:
Isaac Connor 2018-01-18 11:39:09 -05:00
parent 715adb5acb
commit 1dbd8405a4
1 changed files with 9 additions and 5 deletions

View File

@ -224,7 +224,8 @@ CREATE TABLE `Events_Hour` (
`StartTime` datetime default NULL,
`DiskSpace` bigint unsigned default NULL,
PRIMARY KEY (`EventId`),
KEY `Events_Hour_MonitorId_StartTime_idx` (`MonitorId`,`StartTime`)
KEY `Events_Hour_MonitorId_idx` (`MonitorId`)
KEY `Events_Hour_StartTime_idx` (`StartTime`)
) ENGINE=@ZM_MYSQL_ENGINE@;
DROP TABLE IF EXISTS `Events_Day`;
@ -234,7 +235,8 @@ CREATE TABLE `Events_Day` (
`StartTime` datetime default NULL,
`DiskSpace` bigint unsigned default NULL,
PRIMARY KEY (`EventId`),
KEY `Events_Day_MonitorId_StartTime_idx` (`MonitorId`,`StartTime`)
KEY `Events_Day_MonitorId_idx` (`MonitorId`)
KEY `Events_Day_StartTime_idx` (`StartTime`)
) ENGINE=@ZM_MYSQL_ENGINE@;
@ -245,7 +247,8 @@ CREATE TABLE `Events_Week` (
`StartTime` datetime default NULL,
`DiskSpace` bigint unsigned default NULL,
PRIMARY KEY (`EventId`),
KEY `Events_Week_MonitorId_StartTime_idx` (`MonitorId`,`StartTime`)
KEY `Events_Week_MonitorId_idx` (`MonitorId`)
KEY `Events_Week_StartTime_idx` (`StartTime`)
) ENGINE=@ZM_MYSQL_ENGINE@;
DROP TABLE IF EXISTS `Events_Month`;
@ -255,7 +258,8 @@ CREATE TABLE `Events_Month` (
`StartTime` datetime default NULL,
`DiskSpace` bigint unsigned default NULL,
PRIMARY KEY (`EventId`),
KEY `Events_Month_MonitorId_StartTime_idx` (`MonitorId`,`StartTime`)
KEY `Events_Month_MonitorId_idx` (`MonitorId`)
KEY `Events_Month_StartTime_idx` (`StartTime`)
) ENGINE=@ZM_MYSQL_ENGINE@;
@ -265,7 +269,7 @@ CREATE TABLE `Events_Archived` (
`MonitorId` int(10) unsigned NOT NULL,
`DiskSpace` bigint unsigned default NULL,
PRIMARY KEY (`EventId`),
KEY `Events_Month_MonitorId_idx` (`MonitorId`)
KEY `Events_Archived_MonitorId_idx` (`MonitorId`)
) ENGINE=@ZM_MYSQL_ENGINE@;