From cb7390371c6576efd57136491626260567fd5a20 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Mon, 23 Oct 2017 09:21:57 +0200 Subject: [PATCH] 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. --- pandora_console/pandoradb.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 0d749db694..95e93774a4 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -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;