Skip to content

Commit 285e821

Browse files
committed
Add DB index to Alert.last_sent column to speed up listAlertsCmd.
1 parent 31a5669 commit 285e821

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

‎setup/db/create-schema.sql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,7 @@ CREATE TABLE `cloud`.`alert` (
13321332
`last_sent` DATETIME NULL COMMENT 'Last time the alert was sent',
13331333
`resolved` DATETIME NULL COMMENT 'when the alert status was resolved (available memory no longer at critical level, etc.)',
13341334
PRIMARY KEY (`id`),
1335+
INDEX `last_sent` (`last_sent` DESC),
13351336
CONSTRAINT `uc_alert__uuid` UNIQUE (`uuid`)
13361337
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
13371338

‎setup/db/db/schema-40to410.sql‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ ALTER TABLE `cloud`.`inline_load_balancer_nic_map` DROP COLUMN load_balancer_id;
7777
ALTER TABLE upload ADD uuid VARCHAR(40);
7878
ALTER TABLE async_job modify job_cmd VARCHAR(255);
7979

80+
ALTER TABLE `cloud`.`alert` ADD INDEX `last_sent` (`last_sent` DESC) ;
81+
8082
-- populate uuid column with db id if uuid is null
8183
UPDATE `cloud`.`account` set uuid=id WHERE uuid is NULL;
8284
UPDATE `cloud`.`alert` set uuid=id WHERE uuid is NULL;

0 commit comments

Comments
 (0)