Replace the index data_index1 on tagente_datos with a composite index.

Agent data is always searched by agent id and utimestamp. A composite
index makes queries on tagente_datos a lot faster. pandora_db.pl can
still use the existing index on utimestamp. Ref pandora_enterprise#1485.
This commit is contained in:
Ramon Novoa 2017-10-23 09:21:57 +02:00
parent 30f4162d91
commit cb7390371c

View File

@ -99,7 +99,7 @@ CREATE TABLE IF NOT EXISTS `tagente_datos` (
`id_agente_modulo` int(10) unsigned NOT NULL default '0',
`datos` double(22,5) default NULL,
`utimestamp` bigint(20) default '0',
KEY `data_index1` (`id_agente_modulo`),
KEY `data_index1` (`id_agente_modulo`, `utimestamp`),
KEY `idx_utimestamp` USING BTREE (`utimestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
@ -120,7 +120,7 @@ CREATE TABLE IF NOT EXISTS `tagente_datos_string` (
`id_agente_modulo` int(10) unsigned NOT NULL default '0',
`datos` mediumtext NOT NULL,
`utimestamp` int(20) unsigned NOT NULL default 0,
KEY `data_string_index_1` (`id_agente_modulo`),
KEY `data_string_index_1` (`id_agente_modulo`, `utimestamp`),
KEY `idx_utimestamp` USING BTREE (`utimestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;