From 285e8213fed8b0d6a8afc73b686b99a4fcfe5b4a Mon Sep 17 00:00:00 2001 From: Min Chen Date: Wed, 23 Jan 2013 12:38:37 -0800 Subject: [PATCH] Add DB index to Alert.last_sent column to speed up listAlertsCmd. --- setup/db/create-schema.sql | 1 + setup/db/db/schema-40to410.sql | 2 ++ 2 files changed, 3 insertions(+) diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 174f53cd7ba..ead98a588fd 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -1332,6 +1332,7 @@ CREATE TABLE `cloud`.`alert` ( `last_sent` DATETIME NULL COMMENT 'Last time the alert was sent', `resolved` DATETIME NULL COMMENT 'when the alert status was resolved (available memory no longer at critical level, etc.)', PRIMARY KEY (`id`), + INDEX `last_sent` (`last_sent` DESC), CONSTRAINT `uc_alert__uuid` UNIQUE (`uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql index 93949b8e4fa..ed4946e54dd 100644 --- a/setup/db/db/schema-40to410.sql +++ b/setup/db/db/schema-40to410.sql @@ -77,6 +77,8 @@ ALTER TABLE `cloud`.`inline_load_balancer_nic_map` DROP COLUMN load_balancer_id; ALTER TABLE upload ADD uuid VARCHAR(40); ALTER TABLE async_job modify job_cmd VARCHAR(255); +ALTER TABLE `cloud`.`alert` ADD INDEX `last_sent` (`last_sent` DESC) ; + -- populate uuid column with db id if uuid is null UPDATE `cloud`.`account` set uuid=id WHERE uuid is NULL; UPDATE `cloud`.`alert` set uuid=id WHERE uuid is NULL;